PDFBox
  1. PDFBox
  2. PDFBOX-1269

ClassCastException on COSDocument#getDocumentID

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6.0
    • Fix Version/s: 1.7.0
    • Component/s: PDModel
    • Labels:
      None

      Description

      I got this error while trying to save a PDF where I added encryption:
      ava.lang.ClassCastException: org.apache.pdfbox.cos.COSObject cannot be cast to org.apache.pdfbox.cos.COSArray
      at org.apache.pdfbox.cos.COSDocument.getDocumentID(COSDocument.java:379)
      at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.prepareDocumentForEncryption(StandardSecurityHandler.java:300)
      at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1306)
      at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1121)
      at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1102)

      Inspecting the pdf in a REPL, I found out that the ID is not a direct array, but a reference to one. I changed the line 401 of COSDocument.java to use getDictionaryObject instead of getItem and it seemed to fix the problem.

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        1d 11h 33m 1 Andreas Lehmkühler 28/Mar/12 06:43
        Resolved Resolved Closed Closed
        62d 10h 38m 1 Andreas Lehmkühler 29/May/12 17:21
        Andreas Lehmkühler made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Andreas Lehmkühler made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Andreas Lehmkühler [ lehmi ]
        Fix Version/s 1.7.0 [ 12316940 ]
        Resolution Fixed [ 1 ]
        Hide
        Andreas Lehmkühler added a comment -

        I added the fix in revision 1306178 as proposed.

        Thanks for the contribution!

        Show
        Andreas Lehmkühler added a comment - I added the fix in revision 1306178 as proposed. Thanks for the contribution!
        Jean-Philippe Bougie created issue -

          People

          • Assignee:
            Andreas Lehmkühler
            Reporter:
            Jean-Philippe Bougie
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development