Search code examples
ditadita-ot

Can a CSS file be used to generate PDF output?


Does DITA-OT support generation of PDF output with CSS customizations? I think it supports PDF generation using Apache FOP.

I generate both HTML and PDF output and want to use CSS.

Thanks...


Solution

  • The DITA Open Toolkit does not come with default support for using CSS to create PDF. But it can be done. Here is general info on a few ways to do it, to give you an idea:

    • If you have a late-model version of the Oxygen XML editor, you can use the transformation scenario called DITA Map PDF - based on HTML5 & CSS. This is probably the easiest way to go. If you want to have this capability on a server, there is an extra charge. See Oxygen PDF Chemistry for more info: https://www.oxygenxml.com/chemistry-html-to-pdf-converter.html
    • The XML Rocks DITA OT plugin, which requires a commercial PDF processor, one of these: Antenna House Formatter, PDFReactor, Vivliostyle or Prince. https://github.com/xmlrocks/dita-ot-pdf-css-page
    • Do it yourself. One way I have done this is to create normal XHTML output from the DITA OT, and then use a PDF processor and CSS to transform the XHTML to PDF. I have used Antenna House, but other commercial PDF processors (see above) can work also. You should make the XHTML all in one file (all DITA topics merged into one file) by adding this attribute to the <map> element: <map chunk="to-content">