Is there any way I can add multiple images to pdf to create it, and also if I can improve the image by a certain setting before generated pdf?
linzi201719811001:
Is there any way I can add multiple images to pdf to create it
In order to accomplish your requirement, please try following the instructions specified over Add Image to Existing PDF File. In order to add more than one image, add page to Pages collection of PDF file and then add the newly loaded image to specific page instance.
In order to deal with images, we have a separate API named Aspose.Imaging which can be used for Manipulating Images.linzi201719811001:
, and also if I can improve the image by a certain setting before generated pdf?
Hi codewarior,
Hi Aaron,
Please try using following code snippet to fulfill your requirements.
[C#]
// get images names from specific folder
string[] files = Directory.GetFiles(@"C:\pdftest\Images\");
// create Document instnace
Document doc = new Document();
// iterate through all image names loaded earlier
foreach (string file in files)
{
// add page to pages collection of PDF file
Page asposePage = doc.Pages.Add();
// create Imate object
Aspose.Pdf.Image image = new Aspose.Pdf.Image();
// set image file path
image.File = file;
// add image to paragraphs collection of Page instance
asposePage.Paragraphs.Add(image);
}
// save resultant PDF file
doc.Save(“c:/ pdftest / Images_in_PDF.pdf”);