How can i add image to existing pdf

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for .NET (v4)  /  How can i add image to existing pdf

DynamicPDF Merger for .NET (v4) Forum

 Jun 05 2013 1:11 AM
Dear All,

I want to add a image in a specific location of existing pdf.
can you please share source code if you have...
Posted by a ceTe Software moderator
Hello,

Yes, you can add image to the already existing PDF document without any problem.  You will need to build Image class object using the image's file path and setting desired X and Y position then access the page within the PDF using index and add the image to it. Please refer documentation on Image class here. Also below is the sample code for it.

        Dim MyPdf As PdfDocument = New PdfDocument("C:\Input.pdf")
        Dim MyMergeDocument As MergeDocument = New MergeDocument(MyPdf)
        'build Image class object by setting the desired X and Y positions.
        Dim MyImage As Image = New Image("E:\temporary\Images\Winter.jpg", 100, 100, 0.5F)
        'Access the desired page within the PDF.
        Dim MyPage As Page = MyMergeDocument.Pages(0) '0 index is to access first page.
        MyPage.Elements.Add(MyImage)
        MyMergeDocument.Draw("C:\MyDocument_v4.pdf")

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 6:01 AM.