โป๏ธ 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 ...
}
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