Skip to content

XSL-FO Output Formatting

XSL-FO defines output inside <fo:flow> elements. Content moves through a hierarchical structure where "Blocks" of content "Flow" into "Pages" and then to the output media — which in the case of PdfBroker.io is a generated PDF file.

Page, Flow, and Block

The basic nesting structure for XSL-FO output:

<fo:page-sequence>
  <fo:flow flow-name="xsl-region-body">
    <fo:block>
      <!-- Output goes here -->
    </fo:block>
  </fo:flow>
</fo:page-sequence>

Complete Example

A minimal XSL-FO document that produces a single page with the text "Hello PdfBroker.io":

<?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">
      <fo:region-body />
    </fo:simple-page-master>
  </fo:layout-master-set>

  <fo:page-sequence master-reference="A4">
    <fo:flow flow-name="xsl-region-body">
      <fo:block>Hello PdfBroker.io</fo:block>
    </fo:flow>
  </fo:page-sequence>

</fo:root>

This produces a simple PDF with the text "Hello PdfBroker.io" displayed on a blank A4 page.