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

PDImageXObject and UnsupportedOperationException combined with JPEGFactory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Bug
    • 2.0.0
    • None
    • 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.

      The PDImageXObject is created by the JPEGFactory class and the method createFromImage(pdDocument, bufferedImage).
      The PDImageXObject itself will be created but when trying to add metadata to it an error is thrown. Catching the UnsupportedOperationException would work.

      It doesn't work with Java 8 and Java 11 starting from PDFBox 2.0.0.

      // Output
      Sep. 25, 2020 3:21:49 NACHM. sample.application.SampleApplication addMetadataToImage
      SCHWERWIEGEND: null
      java.lang.UnsupportedOperationException: DCTFilter encoding not implemented, use the JPEGFactory methods instead
      	at org.apache.pdfbox.filter.DCTFilter.encode(DCTFilter.java:371)
      	at org.apache.pdfbox.filter.Filter.encode(Filter.java:101)
      	at org.apache.pdfbox.cos.COSOutputStream.close(COSOutputStream.java:93)
      	at java.base/java.io.FilterOutputStream.close(FilterOutputStream.java:188)
      	at org.apache.pdfbox.cos.COSStream$1.close(COSStream.java:236)
      	at org.apache.pdfbox.pdmodel.common.PDMetadata.importXMPMetadata(PDMetadata.java:99)
      	at sample.application.SampleApplication.addMetadataToImage(SampleApplication.java:63)
      	at sample.application.SampleApplication.main(SampleApplication.java:55)

      Attachments

        1. SampleApplication.java
          3 kB
          Robert Fink

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: