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

Catalog object twice in signed file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0 PDFBox
    • 3.0.0 PDFBox
    • Signing

    Description

      The catalog object is twice in the signed file

      1 0 obj
      <<
      /Type /Catalog
      /Version /1.4
      /Pages 2 0 R
      /Metadata 3 0 R
      /OutputIntents [4 0 R]
      /Perms 18 0 R
      /AcroForm <<
      /Fields [22 0 R]
      /SigFlags 3
      >>
      >>
      endobj
      1 0 obj
      <<
      /Type /Catalog
      /Version /1.4
      /Pages 2 0 R
      /Metadata 3 0 R
      /OutputIntents [4 0 R]
      /Perms 18 0 R
      /AcroForm <<
      /Fields [22 0 R]
      /SigFlags 3
      >>
      >>
      endobj
      

      here's a failing test, to be added at the end of CreatePDFATest.java (and probably elsewhere)

      
      // Check that no object numbers are double
      File signedFile = new File(signedPdfaFilename);
      BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(signedFile)));
      String line;
      boolean isIncrementalArea = false;
      Set<String> set = new HashSet<>();
      int linePos = 0;
      while ((line = br.readLine()) != null)
      {
          ++linePos;
          if (line.equals("%%EOF"))
          {
              isIncrementalArea = true;
          }
          if (line.equals("%%EOF"))
          {
              isIncrementalArea = true;
              set.clear(); // for cases with several revisions
          }
          if (line.matches("^\\d+ 0 obj$"))
          {
              int pos = line.indexOf(" 0 obj");
              line = line.substring(0, pos);
              assertFalse(set.contains(line), "object '" + line + " 0 obj' twice in incremental part of PDF at line " +linePos);
              set.add(line);
          }
      }
      br.close();
      

      I don't know why it happens (although I remember I had such a thing years ago when trying different strategies while working on incremental saving in PDFBOX-45)

      Attachments

        1. PDFA_signed.pdf
          54 kB
          Tilman Hausherr

        Activity

          People

            lehmi Andreas Lehmkühler
            tilman Tilman Hausherr
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: