Does anyone know to convert an XML document into a PDF either on the fly or any other way. Failing that an XML document into a Word document. Also we are running a windows based server.
cheers
Welcome to the hell that is my current work project
Yes, it can be done, but you'll need the help of a java program to do it.
We use the Java FOP (check the apache site) application.
The short version:
we generate an xml document, save it locally, do a shell call to the FOP program passing it the location of the XML file, and a location of where we expect the PDF to be saved to. Once its done, we just redirect directly to the pdf.
So yes, it can be done, and once it is done it works VERY well.
Thanks for the advice I had read that this is what you needed...but this won't work in a windows environment will it? If it does how do I go about implementing it?
You're doing a web app, right? So all that means is that your webserver will need the Java runtime installed on it, and your project needs the FOP files included (well, we include them anyway). The FOP can be called direclty without having to have any interface load up or anything (in a way, its almost like you're using just another class, except you have to do a shell command to access it).
If this isn't on a webserver, then you could still do the same thing...but it would mean that each user would need to have the FOP and the java runtime installed on their machine. It actually might be easier in this case to implement it as a webservice, which takes an xml document and converts it on the server, displaying the pdf in a browser.
Right...so I've downloaded the Java JRE and installed it and I have installed the FOP on my C: Drive (just for testing) now can I implement this on the fly from my VB code.
You need to do a shell call from within your code to the FOP application. Before that, you'll have to save your xml to a file somewhere on your hard drive. The FOP app takes three paths as parameters (for the PDF method anyway, there are quite a few other formats it can export to):
- xml file path
- xsl file path
- pdf file path (where the pdf will be saved to)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.