Generating a PDF with several PNG images

Generating a PDF with several PNG images

Forum member · Feb 7, 2014
I am evaluating .NET DynamicPDF to generate a PDF document that contains 1 or more png images. The path and file name of the images are saved in an array. I also need to fit each image to a letter page. Is this possible with DynamicPDF? If so, I will very much appreciate if someone provides a simple C# example. Respectfully, Jorge Maldonado

Re: Generating a PDF with several PNG images

Support · Feb 7, 2014
Hello Jorge, Here is the sample code that shows how to loop through the array of file paths and create a page with the image set to fit the letter sized page. //create a document object. Document document = new Document(); string[] filePaths; //Loop through the array of file paths. for (int i = 0; i < filePaths.Length; i++) { //create a page object Page p = new Page(PageSize.Letter); //create an image object for each image. Image img = new Image(filePaths[i], 0, 0); // set the height and widht of the image to that of the page height/width img.Width = p.Dimensions.Body.Width; img.Height = p.Dimensions.Body.Height; //add image to the page p.Elements.Add(img); //add page to the document document.Pages.Add(p); } document.Draw("output.pdf"); Thanks, ceTe Software Support Team.