Reputation: 3146
Problem:
I have a set of documents (templates) written by marketing guys like manuals, license agreements or advertising materials that can be saved in one of the formats supported by MS Office 2007. During a WS request I have to modify the content of the documents (e.g. fill up empty fields) and generate PDF files in the basis of them.
The problem is my company uses Apache™ FOP which force me to write some home made XMLs more or less like this one
<section>
<header>Regulamin</header>
<content>
<numbered-list>
<list-item>Bla bla <caption>bold something</caption></list-item>
</numbered-list>
</content>
</section>
then this is filled up and transformed by using XSLT to XSL-FO and then finally this is converted to PDF. The real pain is that I have to manually convert Word docs to XMLs.
Does anyone know a better way to deal with generation of PDF in the basis of Word documents ?
Upvotes: 1
Views: 134
Reputation: 8877
As a commercial application my company did, you can examine this:
http://www.xportability.com/Software.xhtml
With the plug-in, you can open the Word documents in Word, add the fields from simple XML content you associate to this (now) template Word document. You export the template as an XSL which generates XSL FO.
Then you can combine XMLs from the user's submittals with that template to get new XSL FO for your engine to process to PDF.
Upvotes: 1
Reputation: 27536
Actually I never tried this tool but JODConverter sounds really promising, you can either run it from console (which might be useful to schedule some batch conversions) or directly from the Java code like
File inputFile = new File("document.doc");
File outputFile = new File("document.pdf");
// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
connection.disconnect();
Upvotes: 0