Questions tagged [xsl-fo]

XSL-FO (XSL Formatting Objects) is a markup language for XML document formatting which is most often used to generate printed content.

From Wikipedia

XSL-FO is part of XSL (Extensible Stylesheet Language), a set of W3C technologies designed for the transformation and formatting of XML data. The other part of XSL is XSLT (Extensible Stylesheet Language Transformations). As of December 12, 2006, the current version of XSL-FO is v1.1.

An XSL-FO document is typically generated using XSLT. An XSLT processor (such as Saxon) evaluates the templates in an XSLT stylesheet to transform your data in your XML vocabulary (or your text or JSON or Markdown or...) into XML in the XSL-FO vocabulary.

Rather than just adding styles to the fixed structure of the source document, the transformation stage is able to also reorder, duplicate, or drop parts of the source document when generating the XSL-FO document, as well as generate new content based on the structure of the source document. This is especially useful when generating tables of contents and indexes that will appear in the formatted document.

The elements in the XSL-FO document represent the formatting objects, and their attributes represent properties of the formatting objects. There are FOs for: blocks; tables and parts of tables; images; links; index entries; and so on. The properties express values such as font size, the expected space between FOs, or whether two FOs should be kept together on the same page. The XSL-FO contains the templates for the types of pages that will be used when the document is made into pages, but the XSL-FO does not contain any information about page breaks or (usually) line breaks.

XSL-FO markup can then be rendered by an FO processor, where it is most commonly used to generate document formats such as PDF, PostScript or RTF. The FO processor uses the structure of the FOs, the constraints expressed by the properties, the sizes of characters in the available fonts, the intrinsic sizes of the graphics, and other factors to lay the content of the XSL-FO out into pages. There is currently one option for viewing the pages in the FO processor application itself, but once the pages are written to a PDF file or other format, the pages can be viewed on screen or printed.

XSL-FO is well suited to applications where you have either a range of broadly similar documents that you want to format in the same style or single large document for which you want consistent styling without much manual effort. The XSLT stage takes care of specifying the right styles for the structures in your source XML and of generating the table of contents and index, and the FO processor automatically lays out the pages in accordance with the specified styles.

Links:

1658 questions
44
votes
9 answers

What's the difference between XSLT and XSL-FO?

What's the difference between XSLT and XSL-FO ? Every resource I've read deal with them as if they were 1, or at least very closely tied..
cwap
  • 10,511
  • 8
  • 44
  • 59
32
votes
5 answers

Use of XSL-FO, CSS3 instead of CSS2 to create Paginated documents like PDF?

There are a lot of old texts, like this 2002 book, stating that we must use "CSS for Web" and "XSL-FO for print". I think in nowadays (2012) we can, finally, to use CSS with render engines that understand paged media of CSS2 and something of CSS3...…
Peter Krauss
  • 11,340
  • 17
  • 129
  • 247
30
votes
2 answers

Scale down to fit an image in FOP

I am using FOP version 1.0 to create PDFs. In one of the pages I'd like to display an image (2552 x 4200 pixel) and scale it down if it doesn't fully fit on the page. As far as I could see on the mailing list the recommended way of doing this would…
Benjamin Muschko
  • 29,316
  • 9
  • 57
  • 81
27
votes
11 answers

Inserting a line break in a PDF generated from XSL FO using

I am using XSL FO to generate a PDF file containing a table with information. One of these columns is a "Description" column. An example of a string that I am populating one of these Description fields with is as follows: This is an example…
Zkoh
  • 2,702
  • 2
  • 16
  • 14
27
votes
4 answers

How do you add a page break in a PDF with XSL-FO?

How do you add a page break into a document with XSL-FO? I'm using Apache FOP to create PDFs, if that makes a difference.
Philip Morton
  • 121,023
  • 36
  • 84
  • 96
26
votes
1 answer

python-pdfkit (wkhtmltopdf) TOC overflow

I currently am creating a perfectly good PDF. there is nothing technically wrong with it. However, the TOC is ugly. The TOC is generated via xsl which is passed through jinja2 for simple details to the top section of the page. I have modified the…
Radio
  • 2,612
  • 1
  • 17
  • 40
25
votes
6 answers

XSL FO inline alignment

I need to get text aligned right and left on the same line. This should be possible, but i can't seem to find a way. I'm using Apache FOP to convert xml to pdf. Can someone help me to get this right?
Ikke
  • 90,705
  • 23
  • 91
  • 118
24
votes
3 answers

How to do an XSL:for-each in reverse order

I am looking to reverse in XSL/FO a for-each loop. for instance the xml with the xsl
Theresa Forster
  • 1,873
  • 3
  • 17
  • 34
21
votes
2 answers

Vertical alignment of text in a table cell

I would like to align the text to bottom in the second cell. The first cell extends to 2 lines, because of insufficent width and that's OK But the text in the second cell is only one line and shows up at the top of the cell. How can I align it to…
AbsoleteMe
  • 273
  • 1
  • 3
  • 8
18
votes
2 answers

How to show page number (N of N) using xslt in PDF Report

I am using XSLT to generate PDF report. My requirements are to display page number in the format of Page N of N (e.g.Page 1 of 3) at the footer of the report. For static values it works fine and it repeats on each page. As total number of pages in…
sns
  • 2,102
  • 4
  • 23
  • 44
17
votes
3 answers

XSL-FO - Empty block elements

I have a quite simple template: How do I tell FO to keep empty lines even if the block is empty.
Jan
  • 593
  • 1
  • 5
  • 20
16
votes
3 answers

Resolving relative paths when loading XSLT files

I need to do an XSL transformation using Apache FOP and I had code like this: //Setup FOP Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out); //Setup Transformer Source xsltSrc = new StreamSource(new File(xslPath)); Transformer transformer =…
Javi
  • 17,777
  • 30
  • 97
  • 132
15
votes
1 answer

How can I display a Unicode character using Apache fop? Showing "?" instead of character.

I been trying to insert a Unicode character ∇ or ▽, so it shows in the PDF generated by Apache FOP. This is what I did so far: First you have to know the correct Unicode codepoint to represent the character according to this basic help Apache…
Juan Marcos
  • 151
  • 1
  • 4
15
votes
10 answers

How do I check for the existence of an external file with XSL?

I've found a lot of examples that reference Java and C for this, but how do I, or can I, check for the existence of an external file with XSL. First, I realize that this is only a snippet, but it's part of a huge stylesheet, so I'm hoping it's…
LOlliffe
  • 1,538
  • 5
  • 18
  • 40
15
votes
3 answers

How to add header and footer for every pages in xsl-fo to generate pdf

please find the following xsl-fo , tried to set header and footer for every page in pdf, but got only header at first page and footer at last page. But here i needed for every page. How to perform this.
Vishnu
  • 989
  • 3
  • 13
  • 23
1
2 3
99 100