XSL-FO Tutorials - Herong's Tutorial Examples - v2.25, by Herong Yang
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:layout-master-set> <fo:simple-page-master master-name="my_page" margin="0.5in"> <fo:region-body/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="my_page"> <fo:flow flow-name="xsl-region-body"> <fo:block>Hello world!</fo:block> </fo:flow> </fo:page-sequence> </fo:root>
Notes about this example:
Now we can run Apache FOP to process hello.fo into a PDF file, hello.pdf:
herong> 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:
Table of Contents
Apache™ FOP (Formatting Objects Processor)
►XSL-FO Document Basics and Examples
Document Top Level Structure Rules
Example - Page-Break-with-Header.fo
Example - Cover-Page-and-Two-Columns.fo
Block-Level Formatting Objects
Inline-Level Formatting Objects
Including Graphics in XSL-FO document
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