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

Free Support Forum - aspose.com

Converting PNG -> PDF on Windows Server

We’re using Aspose Total for Java to convert PNG images to PDF’s.
When we run this operation on Windows 7 (64 bit), everything is OK.
When we run the same program on Windows 2012 server, PDF is broken.

PNG and broken PDF in attachments.

We use the code from this example:


I hope, You can help me.

Hi Krzysztof,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for Java 9.0.0 over Windows Server 2012 where I have used JDK 1.7.0_10 and I am unable to notice any problem. The image file is properly being converted to PDF format. For your reference, I have also attached the resultant PDF file generated over my end. Can you please try using the following code snippet and in case the problem still persists, please share the JDK version and other information. We are sorry for your inconvenience.

com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
com.aspose.pdf.Image image = new com.aspose.pdf.Image();

Thanks for answer.
I’ve checked Your code and it seems to be OK.
But why my code wasn’t good?

Could You check if it works in Your enviroment:

Pdf pdf1 = new Pdf();
//Create a section in the Pdf object
Section sec1 = pdf1.getSections().add();
//Create an image object in the section
aspose.pdf.Image img1 = new aspose.pdf.Image(sec1);
//Add image object into the Paragraphs collection of the section
//Set the path of image file
//Save the Pdf


The code which you have been using is based on legacy Aspose.Pdf for Java (aspose.pdf package). However the one which I have shared is based on new Document Object Model of Aspose.Pdf for Java (com.aspose.pdf package). So we recommend you to please try using the latest DOM approach and in the event of any further query, please feel free to contact.