Converting XSLT-FO to PDF. Maybe integrating Apache FOP?

Hi, I need to generate a PDF Purchase Order and to control the layout. I've tried tFileOutputFTP but it only seems to output a title and one table of data and give you a small amount of control of fonts so it's is too limited. Whether it takes input from FileInputXML or XSLT the result is the same - it completely ignores XSLT where I know I could write the XSLT_FO I need.
I've also look at tFileOutputFTPMetadata but can't work out how to use it and whether it would be of use. I'm not sure what information to pass into it via the shema.
I know there are third party FO processors and renderers but I need to do it all in Talend. I've seen information about Apache FOP, but I don't know how to go about integrating it with Talend. I'm not a java programmer or used to dealing with libraries etc. I was quite please to get tFileOutputFTP installed and using its iText-2.0.8.jar module!
Please can anyway help me with this missing step?
7 REPLIES
One Star

Re: Converting XSLT-FO to PDF. Maybe integrating Apache FOP?

Hi
Sorry. There is no PDF components supported by Talend Official.
I think you have to create custom component for your own requirement.
Besides, I haven't found tFileOutputFTP before in Talend Studio. Is it a custom component?
Regards,
Pedro
One Star

Re: Converting XSLT-FO to PDF. Maybe integrating Apache FOP?

Use tXSLT to to the xsl_fo.

Re: Converting XSLT-FO to PDF. Maybe integrating Apache FOP?

Hi Pedro,
tFileOutputFTP is a custom component which I downloaded from this site after seeing discussions about it when I searched on PDF, XSL etc. It works fine, except that it is very limited - creating just a title and one table regardless of the input. I need to lay out an order document with titles, order number, date etc., two addresses, a table for line items and some totals.
I'm not a java programmer and I don't have the knowledge to write my own component. I'm very surprised that Talend doesn't have one and PDF is a requirement we have for suppliers who cannot receive electronic purchase orders. I've read that you need to use tXSLT to generate an XSLT-FO file from the XML data and XSL stylesheet (and I've done that), but you then need an engine to transform the FO (formatted objects) to PDF. Apache FOP is one such engine, which is why I mentioned it, but tFileOutputFTP doesn't use it.Talend can obviously generate PDFs as it does this for its reporting. Therefore it shouldn't be too difficult to make it available as a component, I would have thought.
Looking at the code for tFileOutputFTP, there are calls to com.lowagie.text, and in particular com.lowagie.text.pdf, which placed into Google brings up the information beow. I assume this is how the author is doing it?
Is there nothing I can do, short of engaging a java programmer?
Jackie
------------------------
com.lowagie.text.pdf
public class: PdfWriter
java.lang.Object
com.lowagie.text.DocWriter
com.lowagie.text.pdf.PdfWriter
All Implemented Interfaces:
PdfPageActions, PdfRunDirection, PdfViewerPreferences, PdfDocumentActions, PdfAnnotations, PdfXConformance, PdfEncryptionSettings, PdfVersion, DocListener
Direct Known Subclasses:
PdfCopy, PdfStamperImp, PdfCopyFieldsImp, Wrt, PdfSmartCopy, PdfCopyFormsImp
A DocWriter class for PDF.
When this PdfWriter is added to a certain PdfDocument, the PDF representation of every Element added to this Document will be written to the outputstream.

Re: Converting XSLT-FO to PDF. Maybe integrating Apache FOP?

Reply to janhess
thanks for your suggestion 'Use tXSLT to to the xsl_fo'. I have got that far, but then I think something is needed to turn the xsl_fo into a PDF document, creating a PDF from the formatted objects? Adobe doesn't like the tXSLT output from my current, very simple attempt, saying it could not read the file "because it is either not a supported file type or because the file has been damaged".
Unless there are particular xsl commands which created FOs which can be read automatically by adobe? If so, would you mind sending me a brief example?
Thanks, Jackie
One Star

Re: Converting XSLT-FO to PDF. Maybe integrating Apache FOP?

You need to run FOP (format object pprocessor on the xsl_fo.
See http://xmlgraphics.apache.org/fop/ for details. It can be called as a batch process from Talend.
A typical command would be
d:\fop-0.20.2\fop.bat -xml c:\xsl\results.XML -xsl c:\xsl\assetmovement520.xsl -pdf c:\xsl\assetmovement.pdf
(the version number shows I haven't used it in a while)
So you could run the whole conversion just from the batch process and probably ignore the tXSLT.

Re: Converting XSLT-FO to PDF. Maybe integrating Apache FOP?

Thanks janhess, that's great!
I was thinking I might need FOP, but didn't realise I could call it from Talend in batch and wanted to do it all via Talend. I'll look up how to do that. I'll also try to download. Presumably I'll need a local windows copy if I'm running my studio on my PC, and a Linux copy for the server where the TAC etc. are. Not very experienced in this area but will give it a go.
Jackie

Re: Converting XSLT-FO to PDF. Maybe integrating Apache FOP?

It's working! Many thanks Janhess.
The Apache fop instructions are great, talking you through installation of the binaries and testing with a simple example file which is provided. There are also lots of .fo examples for all aspects of layout. I've used the windows version so far with my studio, but will also try the Linux ones to use from the TAC.
I installed fop then called it from Talend using tFileList (so far) an dtSystem. After hardcoding initially I was then able to pass a variable into the command line to get it to read in the file generated by Talend. I haven't yet decided which way I'll combine the xml data and xsl - directly or via XSLT. Fop is flexible - it can take just an .fo or a .xml and .xls and generate the -fo on the way. So it will depend on how the fine detail goes, but that's the easy part. Getting from .fo to .pdf was the issue.
Jackie