Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<b>XML to PDF????</b>

Status
Not open for further replies.

swiv

Programmer
Sep 18, 2002
20
GB
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

swiv
 
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.

If you need any other info on this, let me know.

D'Arcy
 
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?

Swiv
 
Oh yeah, it'll work in a windows environment.

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.

hth

D'Arcy
 
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.

sash
 
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)

D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top