Description
Hello,
We are using PDFBox-1.8.11 to convert PDFs to JPG images in our project.
The conversion is working fine for some PDFs but for some of the PDFs, the converted images in JPG format seems to be distorted (esp, flight itenary PDFs). An example of PDF is attached to this ticket for your reference [347254-111788-437553AC1B68331C9B04E6D099E39CB5.pdf].
When this PDF is converted to JPG using PDFbox API, the image returned seems to be corrupted with weird characters.
Below is the code we are using for PDF to JPG conversion.
Kindly help us to find out how this issue can be resolved. Thank you !
public String convertPDFtoJPG(String source , String filepath1, String filePath2, IqiArInvoiceEventSourceVO arInvoiceEventSourceVO ) throws BaseECapException{
String newFile="";
//IPM-5181
String filePathDelimiter = ";";
ArrayList<String> filepaths = new ArrayList<String>();
try{
PDDocument doc=PDDocument.load(new FileInputStream(source));
List<PDPage> pages=doc.getDocumentCatalog().getAllPages();
Iterator<PDPage> i= pages.iterator();
int count=1;
while(i.hasNext()){
PDPage page=i.next();
BufferedImage bi=page.convertToImage();
String saveFilePath = filepath1+filePath2;
if (!new File(saveFilePath).exists())
{ new File(saveFilePath).mkdirs(); }
Thanks,
Avinash