PdfTemplateHorizontalAlignment

6 Jul 20261 minute to read

Public enum to define horizontal alignment options.
```typescript
// Create new document
let document: PdfDocument = new PdfDocument();
// Create a header template
let headerTemplate: PdfPageTemplateElement = new PdfPageTemplateElement({width: 595, height: 50});
// Draw content on header
headerTemplate.graphics.drawString(‘Header’, font, {x: 10, y: 10, width: 575, height: 30}, brush);
// Assign to document template with horizontal alignment
document.template.top = {template: headerTemplate, alignment: PdfTemplateHorizontalAlignment.center};
// Save the document
document.save(‘output.pdf’);
// Destroy the document
document.destroy();

  • center - Centers the template horizontally on the page
  • left - Aligns the template to the left side of the page
  • none - No horizontal alignment is applied
  • right - Aligns the template to the right side of the page