- Code: Select all
PdfDocument doc = new PdfDocument();
PdfPageBase page;
PdfImage image;
//add png files here
String[] str = new String[] { "pic-1.png", "pic-2.png", "pic-3.png" };
for (int i = 0; i < str.Length; i++)
{
page = doc.Pages.Add();
image = PdfImage.FromFile(str[i]);
float width = image.Width * 1f;
float height = image.Height * 1f;
float x = (page.Canvas.ClientSize.Width - width) / 2;
page.Canvas.DrawImage(image, x, 60, width, height);
}
doc.SaveToFile("Image.pdf");
doc.Close();