Articles in this section
Category / Section

How to insert Objects at a specific location of an existing PDF?

1 min read

Insert objects at a specific location of an existing PDF:

You can draw the objects in the specified page, in the specified location, in an existing PDF using the Page. Graphics property.

You can refer to the following code example to draw the image in the specified location in the first page of the existing PDF document.

C#

//Load the document.
PdfLoadedDocument lDoc = new PdfLoadedDocument(@"ExistingPdf.pdf");
//Draw the rectangleat specified location of the existing pdf file.
lDoc.Pages[0].Graphics.DrawRectangle(PdfPens.Blue, new RectangleF(0, 0, 200, 200));
//Create the image.
Image img = Image.FromFile(@"..\..\Data\logo.png");
PdfImage image = PdfImage.FromImage(img);
//Draw the image at specified position.
lDoc.Pages[0].Graphics.DrawImage(image, new PointF(200,0));
//Save and close the document.
lDoc.Save("Sample.pdf");
lDoc.Close(true);

Sample Link:

https://www.syncfusion.com/downloads/support/directtrac/general/ObjectSample1810530620.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied