To generate PDF output from an XML document requires two steps:
|1.||The XML document is transformed by an XSLT stylesheet. An XSLT transformation engine (such as that of RaptorXML) is used for this transformation. The result is an FO document.|
|2.||The FO document is processed by an FO processor (such as Apache's FOP) to generate the PDF output. StyleVision can be set up to pass the FO result of an XSLT transformation to an FO processor. In StyleVision, the result of PDF generation is displayed in the PDF Preview window or can be saved as a file (via the File | Save Generated Files command).|
RaptorXML and PDF
Since RaptorXML does not provide parameters to direct the FO output of an XSLT transformation to an FO processor, you will be left with an FO document as the result of the XSLT transformation step (the first step of the two-step PDF-generation process).
The FO document must now be passed to an FO processor for second-step processing from FO to PDF. The instructions for carrying out this step vary according to the processor being used. For example, in the case of the Apache FOP processor, the following simple command can be used to identify the input FO document and specify the name and location of the output PDF document:
fop -fo input.fo -pdf output.pdf
FOP offers other parameters, and these are listed in the FOP user reference.
FOP and XSLT
One FOP option enables you to specify an input XML file, an input XSLT file, and an output PDF file:
fop -xml input.xml -xslt input.xslt -pdf output.pdf
In this situation, FOP uses its built-in XSLT engine to carry out the first-step XML-to-FO transformation. It then passes the result FO document to FOP for the second-step FO-to-PDF processing.
You should be aware, however, that FOP's built-in engine might not support all the XSLT features that StyleVision and RaptorXML support. Consequently, there could errors if an XSLT stylesheet generated by StyleVision is specified as an input for an XML transformation using FOP's buil-in XSLT engine. In such cases, use the XSLT engine of RaptorXML+XBRL) Server to transform to FO, and then supply the FO file to FOP for processing to PDF.
Batch processing to PDF
A quick and simple way to generate PDF by using RaptorXML for the first-step XSLT transformation and FOP for the second-step FO processing would be to write a batch file that combines the two commands. For example:
raptorxmlserver xslt --input=Test.xml --output=Test.fo Test.xslt
fop -fo Test.fo -pdf Test.pdf
The first command calls RaptorXML and produces test.fo as output. The second command passes test.fo to the FOP processor, which generates the PDF file test.pdf. For more information about batch processing and how batch files can be used to automate processes, see the following section: How to Automate Processing.
© 2019 Altova GmbH