The Print and Page Layout Community Group is developing a series of open-source extensions for XSLT processors so you can run any number of iterations of your XSL-FO processor from within your XSLT transformation, which allows you to make decisions based on formatted sizes of areas.
The extensions are currently available for Java and DotNet and use either the Apache FOP XSL formatter or Antenna House AHF formatter to produce the area trees. Contributions supporting more XSLT–XSL-FO combinations would, of course, be welcome.
A single Java jar file covers four combinations of XSLT processor and XSL-FO formatter:
- Saxon 9.5 and FOP
- Saxon 9.5 and Antenna House
- Xalan and FOP
- Xalan and Antenna House
The DotNet version supports:
- DotNet 4.0 and FOP
- DotNet 4.0 and Antenna House
The graphic below is from a poster done for the Balisage 2014 conference. It shows four ways that the XSLT extensions can be used. Can you see what they are?
Size text to fill available width
Size text to fill available height
- The formatted area fits within the box within a specified tolerance
- The change in font size between successive runs is less than the font size tolerance
- The maximum number of iterations is reached.
Make list item body avoid a long label
Where can I get it?
The main page for the XSLT extensions on on the PPL CG wiki at http://www.w3.org/community/ppl/wiki/XSLTExtensions. The source code for the extensions and the examples are available from the Mercurial repository at https://dvcs.w3.org/hg/ppl and are manually mirrored on GitHub at https://github.com/pplcg/XSLTExtensions.