Apose.PDF not rendering embedded JPEG2000

Our organization (Glyphic Software) licenses Aspose.PDF (Java) to render PDF document pages to PNG. Currently, we are using Aspose.PDF v23.6. We’ve been encountering strange errors when JPEG2000 images are embedded within PDFs, and it occurs often enough to be a concern for our customers. I’ve attached ContainsJPEG2000.pdf (1.3 MB)
PDF from the public domain that illustrates the issue (our customer PDFs contain sensitive information and cannot be shared in this forum). The following PNG files show how different pages of the document render through Aspose. Some render blank and others are garbled.

Here is the code used to render each page.

private static BufferedImage renderPage(int pageIndex, com.aspose.pdf.Page page, float dpi){
    PngDevice pngDevice = new PngDevice(new Resolution(Math.round(dpi)));
    return pngDevice.processToBufferedImage(page);
}

In all cases, the incoming DPI is 225.0 (we’ve tried other hard-coded DPI values to see if change anything to no avail).

We’ve inspected the embedded images in PDF-Xchange Editor and all the underlying meta data for the images in each page looks identical, so not sure what to make of the sporadic nature of the results for rendering each page in this one example document.

Our system logs out as much available metadata as possible on each embedded in both the XImage and XImage.RawParameters objects, here is sample from the image on page one of the attached document

XImage

  • Color Type: java.lang.NumberFormatException “Value out of range [0, 4,294,967,295]: -982701569”
  • Filter Type: 1
    XImage.RawParameters:
  • Bits Per Component: 8
  • Filter:
  • Color Space: DeviceRGB
  • Height: 3507
  • Width: 2480
  • Type: XObject
  • Subtype: Image
  • Decode Parms: null
  • Length: 167076
  • Name:

The same NumberFormatException occurs when rendering the image to grescale using the XImage. getGrayscaled() method, here is the stack trace.

java.lang.NumberFormatException: Value out of range [0, 4,294,967,295]: -2701132005
at com.aspose.pdf.internal.l8n.lj.lI(Unknown Source)
at com.aspose.pdf.internal.l8n.ly.lI(Unknown Source)
at com.aspose.pdf.internal.l8n.ly.lI(Unknown Source)
at com.aspose.pdf.internal.l8n.ly.lu(Unknown Source)
at com.aspose.pdf.internal.l8n.ly.lf(Unknown Source)
at com.aspose.pdf.internal.l8n.ly.ld(Unknown Source)
at com.aspose.pdf.internal.l8n.ly.lI(Unknown Source)
at com.aspose.pdf.internal.l8y.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l8y.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l7y.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l7v.lt.lI(Unknown Source)
at com.aspose.pdf.internal.l7v.lt.lf(Unknown Source)
at com.aspose.pdf.internal.l3t.lt.(Unknown Source)
at com.aspose.pdf.internal.l3t.lt.lI(Unknown Source)
at com.aspose.pdf.internal.l5p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l5p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l5p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l3t.ld.lI(Unknown Source)
at com.aspose.pdf.XImage.lI(Unknown Source)
at com.aspose.pdf.XImage.lv(Unknown Source)
at com.aspose.pdf.XImage.getGrayscaled(Unknown Source)
at com.glyphicsoftware.reader.pdf.PDFPageSource.renderPage(PDFPageSource.java:325)

Although I cannot provide an example client PDF, here is the XImage and XImage.RawParameters metadata and exception stacktrace for a client document page that fails to render with Aspose.PDF (notice this time the error is a NPE vs an NFE)

XImage:

  • Color Type: java.lang.NullPointerException “null”
  • Filter Type: 0
    XImage.RawParameters:
  • Bits Per Component: -1
  • Filter: JPXDecode
  • Color Space: DeviceRGB
  • Height: 3200
  • Width: 2450
  • Type:
  • Subtype: Image
  • Decode Parms: null
  • Length: 1801691
  • Name:

java.lang.NullPointerException: null
at com.aspose.pdf.internal.l5p.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l3t.ld.lI(Unknown Source)
at com.aspose.pdf.XImage.lI(Unknown Source)
at com.aspose.pdf.XImage.lv(Unknown Source)
at com.aspose.pdf.XImage.getGrayscaled(Unknown Source)
at com.glyphicsoftware.reader.pdf.PDFPageSource.renderPage(PDFPageSource.java:325)

We tested rendering both these documents using Apache PDFBox and it successfully renders all pages of this test document along with our client documents which leads us to believe the files are not corrupted. Based on the pages that successfully render, it seems that Aspose.PDF can handle JPEG2000 encoding. Are there known encoding Aspose.PDF cannot handle? This looks like a problem with Aspose.PDF.

@geoff.becker

We are checking it and will get back to you shortly.

1 Like

@geoff.becker

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-43034

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.