Add footer to PDF

This code sample shows how to add a footer in a PDF document.

using (FileStream fileIn = new FileStream(@"..\..\..\inputDocuments\PackingLightBrochure.pdf", FileMode.Open, FileAccess.Read))
{
    Document pdf = new Document(fileIn);
    foreach (Page page in pdf.Pages)
    {
        TextShape text = new TextShape("your footer text here", Font.Helvetica, 14);

        // calculate position of text
        TranslateTransform translate = new TranslateTransform();
        translate.X = (page.Width - text.MeasuredWidth) / 2; // center
        translate.Y = text.MeasuredHeight + 20; // some bottom margin

        // apply the transform to the text
        text.Transform = translate;

        // add text to page
        page.Overlay.Add(text);
    }

    using (FileStream fileOut = new FileStream(@"..\..\stamped.pdf", FileMode.Create, FileAccess.Write))
    {
        pdf.Write(fileOut);
    }
}
Using fileIn As New FileStream("..\..\..\inputDocuments\PackingLightBrochure.pdf", FileMode.Open, FileAccess.Read)
    Dim pdf As New Document(fileIn)
    For Each page As Page In pdf.Pages
        Dim text As New TextShape("your footer text here", Font.Helvetica, 14)

        ' calculate position of text
        Dim translate As New TranslateTransform()
        translate.X = (page.Width - text.MeasuredWidth) / 2
        ' center
        translate.Y = text.MeasuredHeight + 20
        ' some bottom margin
        ' apply the transform to the text
        text.Transform = translate

        ' add text to page
        page.Overlay.Add(text)
    Next

    Using fileOut As New FileStream("..\..\stamped.pdf", FileMode.Create, FileAccess.Write)
        pdf.Write(fileOut)
    End Using
End Using

The original page:

PDF To Add Footer To

The PDF page with the footer:

Pdf With Footer

 

Download PDFKit.NET 4.0
We will send you a download link
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. Alternatively, you may want to use the NuGet package manager to install our library.

Nuget ID

Use the NugetID and start right away, or download the package and install it handmatically