Details
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)