Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.0 PDFBox
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)