Free Support Forum - aspose.com

How to Add image on all pages of PDF using C# with Aspose.PDF for .NET

Hi,
I have to implement ASPOSE.Pdf in classic ASP pages.
I done this by using following code:

  1. set objForm = Server.CreateObject(“Aspose.Pdf.Facades.Form”)

  2. set objGenPDF = Server.CreateObject(“Aspose.Pdf.Facades.Form”)

  3. set outputPDF = Server.CreateObject(“Aspose.Pdf.Document”)

  4. objForm.BindPdf(“MyFile.pdf”)

  5. isFilled = objForm.FillField(fieldName,fieldValue)

  6. objForm.Save(“GenFile.pdf”)

  7. objGenPDF.BindPdf(GenFile.pdf")

  8. outputPDF.Pages.Add_3(objGenPDF.Document.Pages)

  9. outputPDF.Save_2(“FinalOutPutFile.Pdf”)

Using line 7 and 8 i added all my generated PDf files in a single file FinalOutPutFile.pdf. It is working fine in my code.

Now the problem is how i can add image(MyImage.jpg) on my PDF’s each page. Also I have lower left x and y coordinates and width and height to resize image when needed.
Please let me know the way to do this…

@spallavi1

Thank you for contacting support.

We would like to share with you that you can add image stamp on each page of a PDF document by using below code snippet.

    // Open document
    Document pdfDocument = new Document(dataDir+ "AddImageStamp.pdf");
    foreach (Page page in pdfDocument.Pages)
    {
        // Create image stamp
        ImageStamp imageStamp = new ImageStamp(dataDir + "aspose-logo.jpg");
        imageStamp.Background = true;
        imageStamp.XIndent = 100;
        imageStamp.YIndent = 100;
        imageStamp.Height = 300;
        imageStamp.Width = 300;
        imageStamp.Rotate = Rotation.on270;
        imageStamp.Opacity = 0.5;
        // Add stamp to each page
        page.AddStamp(imageStamp);
    }
    dataDir = dataDir + "AddImageStamp_out.pdf";
    // Save output document
    pdfDocument.Save(dataDir);

You may visit Adding Image Stamp in PDF File for more details about image stamp. We hope this will be helpful. Please feel free to contact us if you need any further assistance.