XSL-FO Tutorials - Herong's Tutorial Examples


Copyright © 2006-2024 Herong Yang. All rights reserved.

XSL-FO Tutorials This book is a collection of tutorial notes and sample codes written by the author while he was learning XSL-FO (Extensible Stylesheet Language - Formatting Objects) himself. Topics include: Introduction to XSL, XSL-FO, and Apache FOP; XSL concepts: Area Model, Inline Stacking and Block Stacking; Page layouts: simple-page-master and page-sequence-master; Page regions: region-body, region-before, region-after, region-start and region-end; Formatting objects: Block-Level and Inline-Level Objects; Adding Graphics from Files and SVG Elements; Managing DPI Resolution; Building Tables of Rows and Columns; Managing Lists of Items and Floating Blocks; Adding External and Internal Hyperlinks; Building Table of Contents; Adding Page Headers and Footers; Managing Fonts: Generic Fonts; Adobe Base-14 Fonts; Embedding Fonts; HTML with SVG and MathML to PDF conversion. Updated in 2024 (Version v2.25) with minor updates.

Table of Contents

About This Book

Introduction of XSL-FO

What Is XSL (eXtensible Stylesheet Language)

What Is XSLT (XSL Transformations)

What Is XSL-FO (XSL - Formatting Objects)

hello.fo - Sample XSL-FO document

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

What Is XEP?

Downloading and Installing XEP

RenderX XEP Example - Borders.fo

Introduction of Area Model

What Is XSL Area Model

What Is an Area

Inline Stacking and Block Stacking

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

Layout Declarations

simple-page-master - Simple Page Layout

simple-page-master Attributes and Sub Elements

simple-page-master/region-body Sub Element

region-before and region-after Sub Elements

region-start and region-end Sub Elements

"Body" Region Margin and "Side" Region Extent

Precedence of Side Region Corners

Page Layout and Page Sequence Mapping

What Is "page-sequence-master"

Layout Sequence Example - Cover and Content

Wheat Is "repeatable-page-master-alternatives"?

Layout Sequence Example - Odd and Even Pages

Block-Level Formatting Objects

What Are Block-Level Formatting Objects

What Is "block" Formatting Object?

"block" Formatting Object Examples

Margin Collapsed between Block Areas

space-before/space-after vs. Margin

Block Splitting for Page Break

"block" with Mixed Content

Controlling White Space Characters

What Is "block-container" Formatting Object?

Inline-Level Formatting Objects

What Are Inline-Level Formatting Objects?

What Is "inline" Formatting Object?

"inline" Splitting for Line Break

What Is "line-height" Attribute?

What Is "baseline-shift" Attribute?

"inline" with Mixed Content

FOP Failed on "block" inside "inline"

What Is "inline-container" Formatting Object?

What Is "character" Formatting Object?

What Is "leader" Formatting Object?

What Are "page-number*" Formatting Objects?

Including Graphics in XSL-FO document

Table of Rows and Columns

Table Formatting Object Tree

Table Cell Borders Collapsed and Separated

Table Row Borders and Column Borders

Table Column Headers and Footers

Table and Column Width Control

Table Column and Row Merge or Span

Table with Caption

List, Item, Label, and Body

List Formatting Object Tree

Impact of start-indent on list-item-body

Area Model of List Item, Label and Body

Floating Blocks - "float" and "footnote"

Hyperlinks, Table of Contents and Indexes

What Is "basic-link" Formatting Object?

"basic-link" with "internal-destination" Attribute

Clickable Table of Content

Building Back-of-Book Indexes

Headers and Footers using "static-content"

Page Header in region-before Area

Page Header with 3 Parts

Page Footer with 3 Parts

Page Headers for Multiple Chapters

Font Attributes and Font Families

What Is a Font?

Font Attributes and Generic Fonts

Adobe PDF Base-14 Fonts

Generic Font for Chinese Characters

Apache FOP Font Configurations

RenderX XEP Font Configurations

XEP Font Configuration Settings

XEP Predefined Font Test

Configuring SimHei Font for Chinese Characters

Converting HTML to PDF


Full Version in PDF/ePUB

Keywords: XSL-FO, XML, Stylesheet, Formatting, Object, Tutorial