Aug 26, 2015

Converting DITA to PDF using CSS Paged Media

Alternative approaches for the PDF generation from DITA maps.

Historically PDF conversion of DITA content is closely tied to XSL-FO. However there are alternative ways to get from DITA to PDF. The classic XML addicted will likely disagree but going from DITA XML to PDF through CSS Paged Media appears more reasonable and much easier. The first step is to generate a single-source (X)HTML file form a DITA map.

This can be done by either the DITA Open Toolkit

    dita -f html5 -i my.ditamap -o out/my.html -Droot-chunk-override=to-content

or the XMLMIND DITA converter (DITAC)

    ditac -c single  -f xhtml my.html my.ditamap 

Now you can process the HTML file using one of the a PDF converter like PrinceXML or PDFreactor:

    pdfreactor -s mystyles.css my.html my.pdf

    prince -s mystyles.css my.html my.pdf

All DITA class and outputclass attributes are carried forward into the HTML markup. This will make it easy to write specific CSS styles that match related DITA elements, topics or whatever.

Benefits

  • no XSL-FO needed
  • all styling and layout accomplished by CSS
  • easy integration of third-party Javascript module when needed
  • less complexity, no XSL-FO expert needed
  • reduced costs (cheaper converters, no XSL-FO guru needed) 
  • similar quality as with FO
  • taking advantage of modern CSS features like CSS transformations etc.

Resources

  • Publishing with CSS Paged Media – A review of existing tools and techniques (Slides, XML Prague talk)

Contact