XSL-FO Page Layout and Masters
XSL-FO implements page layouts through "Page Masters" — templates that define page structure. Each template must have a unique name, and PdfBroker.io uses these masters to control the layout of every page in your generated PDF.
Page Size
Control page dimensions with these attributes on <fo:simple-page-master>:
page-width— horizontal dimension (e.g.,210mmfor A4)page-height— vertical dimension (e.g.,297mmfor A4)
Page Margins
Four directional margin attributes manage spacing:
margin-top,margin-bottom,margin-left,margin-rightmargin— shorthand for all four sides
Page Regions
Five region elements structure page layouts:
| Element | Purpose |
|---|---|
<fo:region-body> |
Central content area |
<fo:region-before> |
Top area (header) |
<fo:region-after> |
Bottom area (footer) |
<fo:region-start> |
Left sidebar |
<fo:region-end> |
Right sidebar |
Note
The region-before, region-after, region-start, and region-end are part of the body region. Their extent (size) reduces the available space in region-body.
Example
An A4 page template with 1cm margins and 3cm body margins:
<fo:simple-page-master master-name="A4"
page-height="297mm" page-width="210mm"
margin="10mm">
<fo:region-body margin="30mm" />
<fo:region-before extent="30mm" />
<fo:region-after extent="30mm" />
</fo:simple-page-master>