1

i want to extract the first Page of a PDF-File as an Image. With the following lines it works just fine:

PDDocument doc = PDDocument.load(pdf);
PDFRenderer pdfRenderer = new PDFRenderer(doc);
BufferedImage img = pdfRenderer.renderImageWithDPI(0, 72, ImageType.ARGB);

BUT, if the PDF-File contains a jpeg2000 Image on this Page, i get the following Error in my logfile "Cannot read JPEG2000 image: Java Advanced Imaging (JAI) Image I/O Tools are not installed"

Google told me i can use these Dependencys to fix it

  • jai-imageio-core
  • jai-imageio-jpeg2000

but since its unclear if its allowed to use this in a regular Application i dont want to use them.

So my real Question is:

Is there a way to check if there's a jpeg2000 on this page?

Im using pdfbox-Version: 2.0.19

Pitzas
  • 88
  • 7
  • Have a look at [this link](https://stackoverflow.com/questions/53481280/image-type-unknown-with-pdfbox-and-jpeg2000-sample). Hope that it will be helpful. – Shariq Ali Mar 03 '20 at 14:11
  • This is a terrible idea. Read the license instead. If you still want to know whether there are jpeg2000 images, have a look at the source code of ExtractImages.java. – Tilman Hausherr Mar 03 '20 at 16:52
  • @TilmanHausherr i tryed to understand what im allowed to do, but its soo unclear... – Pitzas Mar 04 '20 at 05:54
  • If you're an individual on his/her own, or just something inside your company, then it's probably no problem. If you want to sell the software, then there may be rules that you have to follow. – Tilman Hausherr Mar 04 '20 at 07:15
  • It is an existing Software Product, so its not for myself unfortunatly – Pitzas Mar 05 '20 at 09:07
  • Then clarify this with your legal department or get legal advice. The alternative would be to ship a viewer that would sometimes show empty pages. That would be weird. – Tilman Hausherr Mar 06 '20 at 10:11

0 Answers0