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

Free Support Forum - aspose.com

Getting Error for pdf to image(jpg) conversion

While converting from pdf to image using aspose, we are getting error in page 2. We have tried with both pngDevice and jpegDevice, still getting the same error
Please let us know the root cause for this issue and possible solution.
Sample Code :
jpegDevice = new JpegDevice(3400, 4400, resolution);
// Convert a particular page and save the image to stream
Page page = pdfDocument.getPages().get_Item(pageCount);
jpegDevice.process(page, byteArrayOutputStream);
S2021011200357_Mask_Sample.pdf.pdf (176.7 KB)

Stacktrace :
class com.aspose.pdf.internal.l9p.lu: Attempted to read past the end of the stream. com.aspose.pdf.internal.l5h.l0n$lI.deserialize(Unknown Source) com.aspose.pdf.internal.l9p.le.deserialize(Unknown Source) com.aspose.pdf.internal.l5h.l1n.lI(Unknown Source) com.aspose.pdf.internal.l9u.lk.lI(Unknown Source) com.aspose.pdf.internal.l9u.ld.lI(Unknown Source) com.aspose.pdf.internal.l2u.lu.lI(Unknown Source) com.aspose.pdf.internal.l2u.lu.lI(Unknown Source) com.aspose.pdf.devices.lI.lI(Unknown Source) com.aspose.pdf.devices.lI.lI(Unknown Source) com.aspose.pdf.devices.ImageDevice.lI(Unknown Source) com.aspose.pdf.devices.JpegDevice.processInternal(Unknown Source) com.aspose.pdf.devices.JpegDevice.process(Unknown Source) PDFToImageConverter.pdfPageToImageConversion(PDFToImageConverter.java:185)


We were able to reproduce the exception in our environment with Aspose.PDF for Java 20.12. Therefore, we have logged it as PDFJAVA-40065 in our issue tracking system. We will further look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

@Parthasarathiy, @karthi988

We have already made our investigation against the issue and found that the PDF file is corrupted. Adobe Acrobat is also unable to recognize the content stream on page 2 (it returns a parse error when checking the file with Adobe Preflight tool). Please see the attached image. The ticket is now closed as Won’t Fix. FileBroken.png (34.5 KB)

Hi @asad.ali,
The contents on page 2 was visible in the chrome viewer but acrobat reader might not be supported. And we are thinking the file may not be corrupted. Kindly check any other possibility to resolve this issue.
I have attached a screen shot for referencescreenshotPage2.PNG (56.3 KB)



We have recorded your feedback along with the ticket and will further check the details accordingly. We will share updates with you as soon as we have some regarding this issue. Please give us some time.