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

ClassCastException when merging PDFs using PDFMergerUtility

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.2.0
    • Utilities
    • None
    • Windows Vista 32-bit, Java 1.5.0_06, PDFBox Head tag (revision 941850)

    Description

      On line 496 of PDFMergerUtility, "target" is cast as a COSObject without checking the type. In some circumstances target will be a COSDictionary which will cause the following ClassCastException.

      java.lang.ClassCastException: org.apache.pdfbox.cos.COSDictionary
      at org.apache.pdfbox.util.PDFMergerUtility.cloneMerge(PDFMergerUtility.java:496)
      at org.apache.pdfbox.util.PDFMergerUtility.cloneMerge(PDFMergerUtility.java:533)
      at org.apache.pdfbox.util.PDFMergerUtility.cloneMerge(PDFMergerUtility.java:491)
      at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:283)
      at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:193)
      at com.xldynamics.common.PdfBoxTest.main(PdfBoxTest.java:40)

      I will provide a patch once I've fixed this and tested it thoroughly. The example PDFs I have contain sensitive information, so unfortunately I can not provide them.

      Attachments

        1. PDFBOX-724.patch
          0.9 kB
          Adam Nichols
        2. PDFBOX-724_clean.patch
          0.9 kB
          Adam Nichols

        Issue Links

          Activity

            People

              Unassigned Unassigned
              adamnichols Adam Nichols
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: