Example - hello.fo

This section provides a tutorial example of an XSL-FO document structure, hello.fo, which declares a simple page layout with a body region and specifies a block area type of formatting object to be presented in the body region of the layout.

To help us understand the XSL-FO document top level structure, let's take a look at our first example, hello.fo, which represents a simplest XSL-FO document:

<?xml version="1.1" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:simple-page-master master-name="my_page" margin="0.5in">
 <fo:page-sequence master-reference="my_page">
  <fo:flow flow-name="xsl-region-body">
   <fo:block>Hello world!</fo:block>

Notes about this example:

Now we can run Apache FOP to process hello.fo into a PDF file, hello.pdf:

C:\herong>\fop\fop -fo hello.fo -pdf hello.pdf
10:05:19 PM org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #1.

Then open hello.pdf with Adobe Acrobat Reader, we will see the "Hello world!" text be rendered on a single page with 0.5 inch margin as shown below:

XSL-FO Example Output - hello.fo

Last update: 2016.

Table of Contents

 About This XSL-FO Tutorial Book

 Introduction of XSL-FO

 Apache™ FOP (Formatting Objects Processor)

 RenderX XEP as an XSL-FO Tool

 Introduction of Area Model

XSL-FO Document Basics and Examples

 Document Top Level Structure Rules

Example - hello.fo

 Example - Page-Break-with-Header.fo

 Example - Cover-Page-and-Two-Columns.fo

 Page Layout Masters

 Block-Level Formatting Objects

 Inline-Level Formatting Objects

 Including Graphics in XSL-FO document

 Table of Rows and Columns

 List, Item, Label, and Body

 Floating Blocks - "float" and "footnote"

 Hyperlinks, Table of Contents and Indexes

 Headers and Footers using "static-content"

 Font Attributes and Font Families

 Apache FOP Font Configurations

 RenderX XEP Font Configurations


 PDF Printing Version