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

QPDF prints warnings about a PDF modified by PDFBOX

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Bug
    • 2.0.27
    • None
    • None
    • None

    Description

      Hi!

      I created a sample PDF file with PDAnnotationLink using PDFBox. Then I changed action from PDActionURI to PDActionGoTo. The modified pdf is correctly working in Okular (a pdf viewer for Linux) but qpdf (version 11.2.0) emits the following warning:

      ❯ qpdf --linearize --replace-input sample_modified.pdf 
      WARNING: sample_modified.pdf, object 2 0 at offset 88: kid 1 (from 0) appears more than once in the pages tree; creating a new page object as a copy 
      qpdf: there are warnings; original file kept in sample_modified.pdf.~qpdf-orig 
      qpdf: operation succeeded with warnings; resulting file may have some problems

      Please find below the code I used to modify pdf. I can also provide code to create that pdf if needed.

      final PDPage page = doc.getPage(0);
      
      final PDPageXYZDestination destination = new PDPageXYZDestination();
      destination.setPage(page);
      
      final PDActionGoTo action = new PDActionGoTo();
      action.setDestination(destination);
      
      final PDAnnotationLink annotationLink = new PDAnnotationLink();
      annotationLink.setAction(action);
      
      float X_MARGIN_LEFT = 50F;
      float BOX_WIDTH = 240F;
      float TEXT_LINE_HEIGHT = 14F;
      
      final PDRectangle position = new PDRectangle();
      final int x = 120;
      final int y = 120;
      position.setLowerLeftX(x);
      position.setLowerLeftY(y);
      position.setUpperRightX(X_MARGIN_LEFT + BOX_WIDTH);
      position.setUpperRightY(y + TEXT_LINE_HEIGHT);
      annotationLink.setRectangle(position);
      
      page.setAnnotations(List.of(annotationLink));
      
      doc.save("sample_modified.pdf");

       

      qpdf complains also about a different pdf (copyrighted) modified in similar way. The warning reads:

      WARNING: file.pdf: reported number of objects (12991) is not one plus the highest object number (12989)

      Attachments

        1. sample_modified.pdf
          0.6 kB
          menteith
        2. sample.pdf
          0.7 kB
          menteith
        3. screenshot-1.png
          36 kB
          Tilman Hausherr
        4. screenshot-2.png
          109 kB
          Tilman Hausherr

        Activity

          People

            Unassigned Unassigned
            menteith85 menteith
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: