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

Free Support Forum - aspose.com

[Aspose.Pdf] How to determine image type in the newest version?

We have utilized Apose.Pdf in version 4.6.0 and we would like to switch to the newest version of Aspose.Pdf (11.4.0). Using the old version it was possible to determine document type using the code below:

(Where 'ximage' is of course an instance of XImage class.)

We have been using the line above to check if image was one of the following types:
memorybmp, svg, exif, jpe, jpg, jpeg, wmf, emf.
Yet, in the newest version, which we are evaluating, there is no such method and ,as a result, the code is not compiling.
Could you please advise on which method should be called in the new version of Aspose.Pdf and how to change our code to obtain the same result as for the code presented above?

Thank you.

Hi Michael,

Thanks for your inquriy. I am afraid currently we do not have any property to identify the image type in PDF document resources. However we will appreciate it if you please share a working sample code that you were using in 4.6.0 as I am afraid I am unable to find the property in that version as well. It will help us to log your requirement exactly.

We are sorry for the inconvenience caused.

Best Regards,

Hi Tilal,

Thank you for your prompt reply. Apologies it was not clear from my previous post, but we are able to obtain the image type using the following code in 4.6.0:
private void processImage(com.aspose.pdf.XImage image) {

String imageType = image.getImage().bJZ().toString();
So there is no dedicated property, enum, etc.but it looks like calling toString() method on the object of the class com.aspose.ms.System.d.c.ag returns the image type. We have been using the code in production for quite a while successfully.


Hi Michael,

Thanks for sharing the details. After initial investigation, I have logged a ticket PDFNEWJAVA-35851 in our issue tracking system for further investigation and rectification. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

Hi Tilal,

Do you have any news about this issue ? I’m trying to dodge my original problem with this solution (Convert PDF to PDF and reducing image size) but it’s seems to be conclusive :frowning:



Hi Florian,

Thanks for your feedback. I am afraid the reported issue is still not resolved, it is pending for the investigation in the queue. We will notify you as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Best Regards,

Hi Michael/Florian,

Thanks for your patience. Our product team has investigated the issue and would like to update you that the image data in XImage stores as pixel map without any specific format. By using the snippet below, you can save it in any format you need (bmp, memorybmp, svg, exif, jpeg, wmf, emf, tiff, icon).

com.aspose.pdf.Document pdfDoc = new

FileOutputStream stream = new FileOutputStream(myDir+"test.png");

pdfDoc.getPages().get_Item(1).getResources().getImages().get_Item(1).save(stream, ImageType.getPng()); // ImageType.getTiff()) and so on..


Please feel free to contact us for any further assistance.

Best Regards,
Hi Tilal/Aspose Team,

Apologies for digging up the old thread, but we used the old Aspose PDF library in order to determine types of embedded images. These types are crucial for us since later we are using extracted images from a PDF file on a standalone html web page. As far as I understand, in the current version of Aspose PDF is impossible to obtain information about all embedded images and, in particular, their exact type or extension? Please advise.


Hi Michael,

Thanks for contacting support.

The images are placed inside PDF file in raster format and while extracting the images, you can specify the extension but they are compressed jpeg. Please take a look over following link for related information on Get Name of Images Embedded in PDF File