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

Tolerate some incorrect Xref in PDF file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.14, 3.0.0 PDFBox
    • 2.0.14, 3.0.0 PDFBox
    • Parsing
    • None

    Description

      Some PDF file may not have correct Xref, and we should tolerate them. Or just log an error but not raise exception.

       pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java | 3 +++
       1 file changed, 3 insertions(+)
      
      diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java b/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
      index 8ca955ed2..b2b28b258 100644
      --- a/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
      +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
      @@ -721,6 +721,9 @@ public class COSParser extends BaseParser
                                           }
                                       }
       
      +                                if( fileOffset == null ) {
      +                                  continue;
      +                                }
                                       List<COSObject> stmObjects = objToBeParsed.get(fileOffset);
                                       if (stmObjects == null)
                                       {
      

      Attachments

        1. Reproduce_Step.png
          67 kB
          Derek Liu

        Activity

          People

            tilman Tilman Hausherr
            liu1985629 Derek Liu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: