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

PDImageXObject and XmpParsingException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Bug
    • 2.0.12, 2.0.13, 2.0.14, 2.0.15, 2.0.16, 2.0.17, 2.0.18, 2.0.19, 2.0.20, 2.0.21
    • None
    • Parsing, PDModel, XmpBox
    • Windows 10 (64 Bit), Java 11.0.8, Netbeans 11.2

    Description

      The goal is to add Metadata to an image within the PDF document.

      It works with Java 11 till PDFBox 2.0.11.
      It doesn't work with Java 11 from PDFBox 2.0.12 till PDFBox 2.0.21.

      In the method retrieveMetadataOfImage(PDImageXObject imageForContentStream) the XMPMetadata is exported again. When use the DomXmpParser and parsing the InputStream an error occurs.
      The error is about the missing "<" right at the beginning.

      // Output
      Sep. 25, 2020 11:56:20 VORM. sample.application.SampleApplication retrieveMetadataOfImage
      SCHWERWIEGEND: null
      org.apache.xmpbox.xml.XmpParsingException: Failed to parse
      	at org.apache.xmpbox.xml.DomXmpParser.parse(DomXmpParser.java:125)
      	at sample.application.SampleApplication.retrieveMetadataOfImage(SampleApplication.java:112)
      	at sample.application.SampleApplication.main(SampleApplication.java:74)
      Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content ist nicht zulässig in Prolog.
      	at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:261)
      	at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
      	at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)
      	at org.apache.xmpbox.xml.DomXmpParser.parse(DomXmpParser.java:121)
      	... 2 more
      

      Attachments

        1. SampleApplication.java
          4 kB
          Robert Fink
        2. SampleApplicationReviewed.java
          5 kB
          Robert Fink

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Robertoni Robert Fink
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: