"fop -fo" - Formatting XSL-FO Files

This section provides a tutorial on how to run the 'fop -fo' command to process an XSL-FO file and render its formatting objects into different presentation formats.

The primary function of Apache™ FOP is to process an XSL-FO file and render its formatting objects into different presentation formats using the "fop -fo" command option.

Here are some variations of the "fop -fo" command option:

fop -fo xxx.fo -pdf xxx.pdf
   Format xxx.fo into a PDF file: xxx.pdf

fop -fo xxx.fo -awt
   Format xxx.fo into a new window on the screen
   
fop -fo xxx.fo -txt xxx.txt
   Format xxx.fo into a text file: xxx.txt

fop -fo xxx.fo -png xxx.png
   Format xxx.fo into PNG files, xxx?.png, one per page

To test the "fop -fo" command option, let's create the following XSL-FO file, hello.fo:

<?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>

Next, run following commands:

herong> fop -fo hello.fo -pdf hello.pdf

10:05:19 PM org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #1.

herong> dir hello.*
     434 hello.fo
   5,172 hello.pdf

Now open hello.pdf with Adobe Acrobat Reader. You will see the text "Hello world!" nicely formatted on page #1 with a 0.5 inch margin as specified in the XSL-FO file.

Table of Contents

 About This Book

 Introduction of XSL-FO

Apache™ FOP (Formatting Objects Processor)

 What Is Apache™ FOP?

 FOP Download and Installation on Windows

 FOP Installation Verification on Windows

 FOP Download and Installation on macOS

 FOP Installation Verification on macOS

 "fop" Command and Options

"fop -fo" - Formatting XSL-FO Files

 "fop -xml -xsl" - Transformation and Formatting

 "fop -xml -xsl -foout" - XSLT Transformations

 RenderX XEP as an XSL-FO Tool

 Introduction of Area Model

 XSL-FO Document Basics and Examples

 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

 Converting HTML to PDF

 References

 Full Version in PDF/ePUB