Skip to content

XSL-FO Block-Level Elements

XSL-FO output goes into blocks that flow through pages within the document structure. Blocks are rectangular containers with distinct regions for spacing, borders, padding, and content — the fundamental building units that PdfBroker.io uses to generate PDFs.

Block Area Components

Each block has these regions (from outside to inside):

  • Space before/after — separation between blocks
  • Margin — empty area outside the block
  • Border — rectangle drawn at the external edge
  • Padding — space between border and content
  • Content — the actual text, images, or graphics

Block Styling Attributes

Blocks support a wide range of styling attributes:

Spacing

margin-top, margin-bottom, margin-left, margin-right, space-before, space-after

Border

Style, color, and width attributes for all four sides: border-before-style, border-after-style, border-start-style, border-end-style

Padding

padding-before, padding-after, padding-start, padding-end

Background

background-color, background-image, background-repeat, background-attachment

Text

font-family, font-weight, font-size, font-style, text-align, text-indent, color

Example

<fo:block font-size="14pt" font-family="verdana" color="red"
  space-before="5mm" space-after="5mm">
  PdfBroker.io
</fo:block>

Tip

While functional, mixing formatting and content directly in blocks creates verbose code. With a little help from XSLT, you can separate concerns through templating. See XSL-FO with XSLT.