Hi,
Hi Sandeep,
Thanks for contacting support.
Please try using the following code snippet based on new DOM approach. Please note that Aspose.Pdf.Generator is a legacy approach and it will be deprecated in near future. Therefore we recommend using the new DOM approach.
[C#]
//open document
Document pdfDocument = new Document();
Aspose.Pdf.Image image = new Aspose.Pdf.Image();
image.File = "c:pdftestimage001 (1).png";
for (int counter = 1; counter < 10; counter++)
{
pdfDocument.Pages.Add().Paragraphs.Add(image);
}
//save modified PDF
pdfDocument.Save("c:pdftestMultipleImage_output.pdf");
Hi,
Hi Sandeep,
Hi Sandeep,
We have a method named CompleteClone(..) in Aspose.Pdf.Generator.Image which creates a clone of a previously created object. However, even when using this approach to place multiple instances of an image on various pages, a separate copy of the image is placed, and hence it produces a PDF file with a size equal to Image Size X number of times it is repeated inside the PDF.
I am afraid currently we cannot accomplish the requirement with the legacy Aspose.Pdf.Generator approach.
C#
//open document
Aspose.Pdf.Generator.Pdf pdfDocument = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Image image = new Aspose.Pdf.Generator.Image();
image.ImageInfo.File = "c:/pdftest/BarCode_Image.png";
image.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Png;
for (int counter = 1; counter < 10; counter++) {
Aspose.Pdf.Generator.Image newimage = image.CompleteClone() as Aspose.Pdf.Generator.Image;
pdfDocument.Sections.Add().Paragraphs.Add(newimage);
}
// compress the PDF file contents
pdfDocument.CompressionLevel = 1;
// save modified PDF
pdfDocument.Save("c:/pdftest/MultipleImage_output.pdf");