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

Error occurred while processing the File:expected='endstream' actual='' at offset 142940

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Not A Bug
    • 1.8.9
    • None
    • Parsing
    • None
    • Development

    Description

      Hi All

      I am getting this error for a specific file while loading. 

      PDDocument doc = PDDocument.load(new File(k))

      Error occurred while processing the File:expected='endstream' actual='' at offset 142940.

      I am not sure what is the problem here. Can you guys recommend what i need to do to fix this issue.

      My code looks like this 

      PDFMergerUtility mergePdf = new PDFMergerUtility()

      def i = 0
              pdfFileUrlList.each { k, v ->

                    i++
                  PDDocument doc = PDDocument.load(new File(k))
                  if (doc.isEncrypted())

                   

      {                 log.info("Document is encrypted :" + k)                        doc.decrypt("")                   doc.setAllSecurityToBeRemoved(true)                   def newFile = tempPath + "decryptFile_" + i + ".pdf"                 doc.save(newFile)                    mergePdf.addSource(new File(newFile))                 }

                  else

                   

      {                               mergePdf.addSource(k)             }

                  doc.close()
              }

       

      Below is the exception stacktrace

       

      java.io.IOException: expected='endstream' actual='' at offset 142940
          at org.apache.pdfbox.pdfparser.BaseParser.parseCOSStream(BaseParser.java:607)
          at org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:650)
          at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1158)
          at org.apache.pdfbox.pdmodel.PDDocument$load.call(Unknown Source)

      Attachments

        Activity

          People

            Unassigned Unassigned
            getoffersrt@gmail.com Ravi Thapa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: