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

Free Support Forum - aspose.com

Newbie here -I need some sample code to convert a png image to pdf document

Please help as I am new to this application. I have a chart image in png format created with ChartFX. I need to transform this image into a pdf document. I cannot find any clear examples so all help is greatly appreciated.

Thanks Don

Hello Don,

Thanks for considering Aspose.Pdf

Converting "png" format image into Pdf is very simple like converting any other format. Kindly use following piece of code to convert Png format image to Pdf.

//Instantiate a Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();

//Create a section in the Pdf object
Section sec1 = pdf1.Sections.Add();

//Create an image object in the section
Aspose.Pdf.Image image1 = new Aspose.Pdf.Image(sec1);

//Add image object into the Paragraphs collection of the section

//Set the path of image file
image1.ImageInfo.File = "C:/pdftest/Flower.png";

//Set the type of image using ImageFileType enumeration
image1.ImageInfo.ImageFileType = ImageFileType.Png;

//Set image title
image1.ImageInfo.Title = "ChartFX image";

//Save the Pdf

For more information regarding conversion of image file to Pdf, kindly visit Use Image from Local Disk