Add footer to PDF

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