We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com


Can you extract a jpg2000 with Aspose.pdf for java?


Thanks for contacting support.

Would you please share some more details about your requirement of extracting JPEG 2000 (i.e jpx, jp2, etc) images? Do you want to add mentioned type of images inside PDF? We will really appreciate if you can please share some more details along with a sample image file. We will check the details and accordingly and share our feedback.

We are trying to extract an image from a PDF. I can extract a jpeg but when I try a jpeg2000 the Aspose library fails to extract the image.


   public static void main(String[] args) throws Exception {
          // Open a document
          System.out.println("I'm here");
          //Document pdfDocument = new Document("input.pdf");
          Document pdfDocument = new Document("C:\\inwork\\Aspose.Pdf-for-Java-master\\Examples\\balloon-jp2.pdf");
          //Document pdfDocument = new Document("C:\\inwork\\Aspose.Pdf-for-Java-master\\Examples\\ds6_cluster_install.pdf");
          // Extract a particular image
          XImage xImage = pdfDocument.getPages().get_Item(1).getResources().getImages().get_Item(1);
          //XImage xImage = pdfDocument.getPages().get_Item(2).getResources().getImages().get_Item(1);
          // Create stream object to save the output image
          //java.io.OutputStream output = new java.io.FileOutputStream("output.png");
          java.io.OutputStream output = new java.io.FileOutputStream("output.jpg");
          // Save the output image
          //xImage.save(output, ImageType.getPng());

balloon-jp2.pdf (659.6 KB)


Thanks for sharing code snippet and respective document.

We have tested the scenario in our environment and observed that the API raised java.lang.NullPointerException Exception, while extracting the image from PDF document. For the sake of correction, we have logged this issue as PDFJAVA-37185 in our issue tracking system. We will further investigate the issue and keep you posted with the status of its rectification. Please be patient and spare us little time.

We are sorry for the inconvenience.