Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4110

PDF to JPG conversion is returning distorted images

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Not A Bug
    • Affects Version/s: 1.8.11
    • Fix Version/s: None
    • Component/s: Rendering
    • Labels:

      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

        Attachments

        1. 347254-111788-437553AC1B68331C9B04E6D099E39CB5.pdf
          40 kB
          Avinash
        2. 1000-test-2.jpg
          142 kB
          Avinash
        3. 1000-test-1.jpg
          170 kB
          Avinash
        4. flight_receipt.pdf
          40 kB
          Avinash

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              amullapudi Avinash
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: