Hi,
Is it possible to insert an image to an existing PDF file, at a specific position?
For example, the PDF creator first setup a specific position with a variable, then I use your PDF component to search for the variable, then insert image to replace this variable.
Please advice if it is doable and how to do it. Thanks.
Hi Chen,
You can use Aspose.Pdf.Kit to add an image at a particular location, specified by coordinates. Please see an example in this help topic. However, I’m not quite sure what you mean by ‘specific position with a variable’. If you mean that you have specified a location by using some empty or sample image where you want to replace your actual image then you can do that with Aspose.Pdf.Kit using ReplaceImage method. You can find example in the following article: Manipulate Images in an Existing PDF File.
I hope this helps. If you find any further questions, please do let us know.
Regards,
Hi,
Your information is useful, the first one insert image by specified coordinates works.
However, the second one doesn’t work from my side.
I tried to replace every image in attached pdf, but after replaced and saved it mains the original one. I just copied second link’s code, but seems doesn’t work.
Please advice, thank you.
Hi Chen,
I have tried the following code snippet at my end to replace multiple images and noticed that only few of them are being replaced:
PdfContentEditor pdfEditor = new PdfContentEditor();
pdfEditor.BindPdf(“8122010438.pdf”);
//replacing individual images
pdfEditor.ReplaceImage(1, 1, “aspose-logo.jpg”);
pdfEditor.ReplaceImage(1, 2, “aspose-logo.jpg”);
pdfEditor.ReplaceImage(1, 3, “aspose-logo.jpg”);
pdfEditor.ReplaceImage(1, 4, “aspose-logo.jpg”);
pdfEditor.ReplaceImage(1, 5, “aspose-logo.jpg”);
pdfEditor.ReplaceImage(1, 6, “aspose-logo.jpg”);
pdfEditor.Save(“output.pdf”);
I have logged this issue as PDFKITNET-26478 in our issue tracking system. Our team will investigate it and we'll try to make sure that all the images are replaced in the PDF file. You'll be notified via this forum thread once it is resolved.
We're sorry for the inconvenience.
Regards,