Prince XML and oXygen

Here should go questions about transforming XML with XSLT and FOP.
ra0543
Posts: 80
Joined: Wed Jan 14, 2009 12:50 pm

Prince XML and oXygen

Post by ra0543 »

A post today on a PrinceXML forum (http://www.princexml.com/bb/viewtopic.p ... 91&start=0) suggests Prince can be integrated with Oxygen to take the result of a transformation and process it directly into PDF using CSS. I'm not familiar with the FO set up of Oxygen, not having used it before. I'm wondering if someone here has tried this successfully and/or can provide (or point to) some clear instructions about how to set it up to do this.

Cheers
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Prince XML and oXygen

Post by adrian »

Hi,

Please note that this is not a "by design" use, it just so happens that you can use Prince as a fake FO Processor or even as a fake XSLT Custom Engine in Oxygen. But you will sometimes feel the lack of an additional argument for the CSS in the processing with Prince.

Prince as an FO Processor - XHTML -> PDF
You can configure Prince as a fake FO Processor to further process the result of an XHTML transformation into PDF.
Go to Options -> Preferences -> XML -> XSLT-FO-XQuery -> FO Processors.
Click New, give it a proper name: "Prince". In the command line use the path to the prince command line tool and the appropriate arguments.

Code: Select all

"C:\Program Files\Prince\Engine\bin\prince.exe" ${fo} -o ${out}
If you have a custom CSS that you want to use with Prince you might also want to add to the command line:

Code: Select all

-s <C:\path\to\your\css\file.css>
Now you can use Prince in a transformation scenario in the FO Processor tab for any transformation that outputs xhtml.
e.g.
In the Document -> Transformation -> Configure Transformation Scenario dialog duplicate one of Oxygen's default transformations to XHTML(DocBook XHTML, TEI XHTML). Then select the FO Processor tab, enable "Perform FO Processing" and from the Processor combo choose the name you gave to the FO Processor defined above, "Prince".
Go to the Output tab and change the file extension from the "Save As" field to ".pdf".
When you apply this transformation, first it will process the XML with the XSLT(just like before) and the XHTML result of that transformation will be further processed by Prince into PDF.

Prince as an XSLT Custom Engine - XML+CSS -> PDF
You can configure Prince as a fake XSLT Custom Engine to use it in a transformation of an XML file with a CSS file into PDF.
Go to Options -> Preferences -> XML -> XSLT-FO-XQuery -> Custom Engines.
Click New, choose as engine type XSLT(you will be able to use it for XMLs) and it a proper name: "Prince". In the command line use the path to the prince command line tool and the appropriate arguments.

Code: Select all

"C:\Program Files\Prince\Engine\bin\prince.exe" ${xml} -s ${xsl} -o ${out} 
With this custom engine you will be to use a CSS file in the XSL field from the transformation scenario.

e.g. of use
From the Oxygen samples open "personal.xml", create a new scenario: Document -> Transformation -> Configure Transformation Scenario, New
In the XML URL field leave: ${currentFileURL}
In the XSL URL use the CSS file. In our case("personal.css") we can use a pattern since our CSS file has the same name as the XML file: ${cfdu}/${cfn}.css
From the Transformer combo choose the custom engine you defined earlier, "Prince". Do not use a FO Processor.
In the Output tab set the output file in the "Save As" field : ${cfdu}/${cfn}.pdf , enable "Open in browser" and from the "Show as" group remove the "XML" checkbox.

When you transform this, Prince will process the current XML with the specified CSS into PDF.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply