Hi. you can use this UDF to convert the PDF to byteArray.
public static byte[] loadFile(String sourcePath) throws IOException { byte[] buffer = new byte[8192]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream inputStream = null; int bytesRead; try { inputStream = new FileInputStream(sourcePath); while ((bytesRead = inputStream.read(buffer)) != -1) { baos.write(buffer, 0, bytesRead); } } finally { if (inputStream != null) { inputStream.close(); } } return baos.toByteArray(); }