โ™ป๏ธ Reusable Templates (Form XObjects)

Define headers, footers, and watermarks once โ€” use them on every page without duplication.

C# โ€” Reusable Templates
// Define header once
var header = doc.CreateFormXObject(612, 35);
header.FillRectangle(0, 0, 612, 35,
    new PdfDrawOptions {
        FillColor = new PdfColor(0.12, 0.25, 0.55)
    });
header.AddText("COMPANY REPORT", 72, 10,
    new PdfTextOptions {
        Font = StandardFont.HelveticaBold,
        FontSize = 10,
        Color = new PdfColor(1, 1, 1)
    });

// Use on every page (artifact)
for (int i = 0; i < 10; i++)
{
    var page = doc.AddPage();
    page.BeginArtifact(PdfArtifactType.Pagination);
    page.AddFormXObject(header, 0, 757);
    page.EndArtifact();

    // ... add tagged content ...
}
Screenshot of the Reusable Templates PDF showing three pages side by side, each with an identical dark blue header bar containing 'COMPANY REPORT โ€” CONFIDENTIAL' in white text, a gray footer line with 'Generated by ObviousPDF', and unique section content on each page โ€” demonstrating that the header and footer are defined once as Form XObjects and reused

You should see three pages each sharing an identical dark-blue header bar reading "COMPANY REPORT โ€” CONFIDENTIAL" in white bold text, and an identical grey footer line with "Generated by ObviousPDF" in italic grey and a centred page number. Only the section headings (Section 1, Section 2, Section 3) and body paragraphs differ per page.
File: 15_form_xobjects.pdf

โ™ฟ Accessibility Tip

Headers and footers are repetitive navigation aids โ€” always mark Form XObject placements as PdfArtifactType.Pagination so screen readers skip them on every page.