Hello Example of XSL-FO - Hello.fo


How to write a Hello example of XSL-FO?

✍: FYIcenter.com


XSL-FO (Extensible Stylesheet Language - Formatting Objects) is an XML based language that can be used to describes the way pages are set up. Here is the XML source code of a simple XSL-FO file, Hello.fo:

<?xml version="1.0" encoding="utf-8"?>
<!-- hello.fo
     Copyright (c) 2018 FYIcenter.com
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:simple-page-master master-name="myPage">
      <fo:region-body margin="1in"/>
  <fo:page-sequence master-reference="myPage">
    <fo:flow flow-name="xsl-region-body">
      <fo:block>Hello world!</fo:block>

You can use the "fop" command to generate a PDF version of Hello.fo:

\fyicenter>cd \local\fop-2.x\fop

\local\fop-2.x\fop>fop Hello.fo Hello.pdf
... org.apache.fop.events.LoggingEventListener processEvent
INFO: Rendered page #1.

The output PDF file Hello.pdf has a single page with "Hello world!" printed at the top left corner with 1 inch margin.


FOP Commands and Examples

What Is XSL-FO Language

Introduction of FOP

⇑⇑ FAQ for FOP (Formatting Object Processor)

2015-11-26, 2133🔥, 0💬