PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.

Add Stamp to PDF

This code sample shows how to stamp a PDF in C#. You can stamp images and watermarks to your PDF for example.

const string inputFile = @"..\..\..\inputDocuments\PackingLightBrochure.pdf";
using (FileStream inFile = new FileStream(inputFile, FileMode.Open, FileAccess.Read))
    // open the source document
    var document = new Document(inFile);

    // stamp each page
    for (int i = 0; i < document.Pages.Count; i++)
        Page page = document.Pages[i];

        // create a shape image
        ImageShape image = new ImageShape(@"..\..\logo.gif");

        TranslateTransform translate = new TranslateTransform();
        image.Transform = translate;

        // position at center of page
        image.Width *= 2;
        translate.X = page.Width / 2 - image.Width / 2;
        translate.Y = page.Height / 2 - image.Height / 2;

        // at the shape image to the overlay of the page

    // write the modified document to disk
    const string fileName = @"..\..\stampimage.pdf";
    using (FileStream outFile = new FileStream(fileName, FileMode.Create, FileAccess.Write))
Const inputFile As String = "..\..\..\inputDocuments\PackingLightBrochure.pdf"
Using inFile As New FileStream(inputFile, FileMode.Open, FileAccess.Read)
    ' open the source document
    Dim document = New Document(inFile)

    ' stamp each page
    For i As Integer = 0 To document.Pages.Count - 1
        Dim page As Page = document.Pages(i)

        ' create a shape image
        Dim image As New ImageShape("..\..\logo.gif")

        Dim translate As New TranslateTransform()
        image.Transform = translate

        ' position at center of page
        image.Width *= 2
        translate.X = page.Width / 2 - image.Width / 2
        translate.Y = page.Height / 2 - image.Height / 2

        ' at the shape image to the overlay of the page

    ' write the modified document to disk
    Const fileName As String = "..\..\stampimage.pdf"
    Using outFile As New FileStream(fileName, FileMode.Create, FileAccess.Write)
    End Using
End Using

The original PDF:

PDF Without Stamp

The PDF with the stamp:

PDF Add Stamp

Download PDFKit.NET 4.0
We will send you a download link

  • This field is for validation purposes and should be left unchanged.
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link.