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

Class Cast thrown when merging PDF's

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0
    • 1.2.0
    • Utilities
    • None
    • Windows Vista 64/Java6

    Description

      When merging PDF's with the code:

      PDFMergerUtility pm = new PDFMergerUtility();
      File destPdf = File.createTempFile("TestFax_", ".pdf");
      pm.setDestinationFileName(destPdf.getAbsolutePath());

      for (File pdfFile:pdfFiles)

      { pm.addSource(pdfFile); }

      try

      { pm.mergeDocuments(); return PDDocument.load(destPdf); }

      catch (COSVisitorException e)

      { LoggerFactory.getLogger(getClass()).error("Merging PDF's", e); }

      I get the exception:

      10:44:09.511 [Thread-6] ERROR midwifemate.client.ui.PrintDialog$7 - null
      java.lang.ClassCastException: org.apache.pdfbox.cos.COSDictionary cannot be cast to org.apache.pdfbox.cos.COSObject
      at org.apache.pdfbox.util.PDFMergerUtility.cloneMerge(PDFMergerUtility.java:438) [classes/:na]
      at org.apache.pdfbox.util.PDFMergerUtility.cloneMerge(PDFMergerUtility.java:475) [classes/:na]
      at org.apache.pdfbox.util.PDFMergerUtility.cloneMerge(PDFMergerUtility.java:433) [classes/:na]
      at org.apache.pdfbox.util.PDFMergerUtility.appendDocument(PDFMergerUtility.java:227) [classes/:na]
      at org.apache.pdfbox.util.PDFMergerUtility.mergeDocuments(PDFMergerUtility.java:134) [classes/:na]
      at com.selene.mm.model.fax.Fax.getPdfForFaxing(Fax.java:254) [classes/:na]
      at com.selene.mm.model.fax.Fax.getPdfForPrinting(Fax.java:162) [classes/:na]
      at midwifemate.client.ui.PrintDialog$7.run(PrintDialog.java:415) [classes/:na]
      at midwifemate.ui.util.JProgressPane$1$1.run(JProgressPane.java:51) [classes/:na]
      at java.lang.Thread.run(Thread.java:619) [na:1.6.0_10-rc2]

      PDF's attached.

      Attachments

        1. PDFBOX563-TestFax_merged.pdf
          401 kB
          Andreas Lehmkühler
        2. TestFax_56972.pdf
          411 kB
          Yonas Jongkind
        3. TestFax_56974.pdf
          5 kB
          Yonas Jongkind
        4. TestFax_56976.pdf
          5 kB
          Yonas Jongkind

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yonas.jongkind@gmail.com Yonas Jongkind
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: