Skip to content

XSL-FO Document Structure

XSL-FO documents are XML files with output information. They contain layout and content details and typically use the file extensions .fo, .fob, or .xml — all of which PdfBroker.io accepts for PDF generation.

Document Structure

<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <fo:layout-master-set>
    <fo:simple-page-master master-name="A4">
      <!-- Page template goes here -->
    </fo:simple-page-master>
  </fo:layout-master-set>

  <fo:page-sequence master-reference="A4">
    <!-- Page content goes here -->
  </fo:page-sequence>

</fo:root>

Structure Explained

Element Purpose
<fo:root> The root element, which declares the XSL-FO namespace
<fo:layout-master-set> Contains one or more page templates (masters)
<fo:simple-page-master> Defines an individual page template with a unique master-name attribute
<fo:page-sequence> Describes page contents, referencing a template via master-reference

The XML declaration is required at the start of the document. The <fo:root> element must declare the XSL-FO namespace http://www.w3.org/1999/XSL/Format.