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

ClassCastException CosString cannot be cast to COSName

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8.2
    • 1.8.6, 2.0.0
    • Parsing
    • None
    • Ubuntu Linux & Windows 7 (both JDK6)

    Description

      Opening and saving a PDF causes this exception in 1.8.2:

      Exception in thread "main" java.lang.ClassCastException: org.apache.pdfbox.cos.COSString cannot be cast to org.apache.pdfbox.cos.COSName
      at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:507)
      at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:435)
      at org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1122)
      at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:552)
      at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1501)
      at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1324)
      at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1305)

      The PDF is here: http://digitalcorpora.org/corp/nps/files/govdocs1/008/008677.pdf

      Code to reproduce the exception:
      PDFParser parser = new PDFParser(new FileInputStream(new File("008677.pdf")));
      parser.parse();
      File temp = File.createTempFile("temp-", ".pdf");
      parser.getPDDocument().save(temp);
      parser.getDocument().close();

      Attachments

        1. testPDF_twoAuthors.pdf
          12 kB
          Tim Allison

        Issue Links

          Activity

            People

              tilman Tilman Hausherr
              willp-bl William Palmer
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: