From XML to HTML and PDF

W

Wendy S

The current version of my project involves reading from a database, setting
properties in a JavaBean (they're all String or String[]) and then using
JSTL to iterate over the various arrays (and arrays-of-arrays) and display
HTML. They wanted a 'printer friendly' version, so I wrote a different JSP
that doesn't have the menus and navigation and just displays the data.

But it's not well written, and adding things (which they ask for at least
weekly) is difficult. So, the rewrite will commence soon and I'm looking
for better options.

The data is multi-valued and deeply nested - XML is the natural format for
it. Once I get that part settled, I need to go from XML to either HTML (via
a Struts/Tiles webapp) and to PDF for the 'printer friendly' version. Using
Java, obviously. :)

Can someone help me sort out the alphabet soup of acronyms and projects to
do this?

I'm thinking XSLT (and CSS) will turn the XML into nicely formatted HTML.
Any other suggestions for that part?

And I'm already using iText to do PDF in another project, though that one
does not involve XML. XML to PDF searching turns up FOP, can anyone comment
on that? (It looks complicated!)

Thanks,
Wendy
 
J

John

Wendy said:
The current version of my project involves reading from a database, setting
properties in a JavaBean (they're all String or String[]) and then using
JSTL to iterate over the various arrays (and arrays-of-arrays) and display
HTML. They wanted a 'printer friendly' version, so I wrote a different JSP
that doesn't have the menus and navigation and just displays the data.

But it's not well written, and adding things (which they ask for at least
weekly) is difficult. So, the rewrite will commence soon and I'm looking
for better options.

The data is multi-valued and deeply nested - XML is the natural format for
it. Once I get that part settled, I need to go from XML to either HTML (via
a Struts/Tiles webapp) and to PDF for the 'printer friendly' version. Using
Java, obviously. :)

Can someone help me sort out the alphabet soup of acronyms and projects to
do this?

I'm thinking XSLT (and CSS) will turn the XML into nicely formatted HTML.
Any other suggestions for that part?

And I'm already using iText to do PDF in another project, though that one
does not involve XML. XML to PDF searching turns up FOP, can anyone comment
on that? (It looks complicated!)

Thanks,
Wendy

I am doing something similar, but I'm not using as much technology as
you mentioned. I just translate the data to XHTML. If you need to print
it then you can convert (X)HTML to PostScript then pipe it straight to a
network printer. PS to PDF is trivial if you need PDFs as an option.

John
 
A

asaguden

Regarding Java to XML:
Try using xstrema [http://xstream.codehaus.org/], a library
to convert your java Value objects to XML.

When that is done....

Regarding XML to HTML:
XSLT is a good approach. Clean separation between data and
logic.

Regarding XML to PDF:
Since you are already using Itext, take a look at UJAC
[http://ujac.sourceforge.net/]. It is alibrary built on top of Itext.
In the "Print" module, you can convert from XML to PDF.

Good luck.
_________________________________________________________________
 
A

anonymous

Wendy said:
The current version of my project involves reading from a database, setting
properties in a JavaBean (they're all String or String[]) and then using
JSTL to iterate over the various arrays (and arrays-of-arrays) and display
HTML. They wanted a 'printer friendly' version, so I wrote a different JSP
that doesn't have the menus and navigation and just displays the data.

But it's not well written, and adding things (which they ask for at least
weekly) is difficult. So, the rewrite will commence soon and I'm looking
for better options.

The data is multi-valued and deeply nested - XML is the natural format for
it. Once I get that part settled, I need to go from XML to either HTML (via
a Struts/Tiles webapp) and to PDF for the 'printer friendly' version. Using
Java, obviously. :)

Can someone help me sort out the alphabet soup of acronyms and projects to
do this?

I'm thinking XSLT (and CSS) will turn the XML into nicely formatted HTML.
Any other suggestions for that part?

And I'm already using iText to do PDF in another project, though that one
does not involve XML. XML to PDF searching turns up FOP, can anyone comment
on that? (It looks complicated!)

Thanks,
Wendy
I'd also suggest using XSLT. Most of my xml/xsl based projects have
benefited much from using this approach. After the initial coding, 80%
of the change requests have been for the GUI. Easily accomplished using XSL.
 
A

alan

And I'm already using iText to do PDF in another project, though that one
does not involve XML. XML to PDF searching turns up FOP, can anyone comment
on that? (It looks complicated!)

I'm going to repeat what everyone else said.

Use XSLT. You'll have to learn functional programming, but there
is a lot of help out there, a lot of good texts and the xsl-list
listserv. Read over Jenni Tennison's web site. Get the XSLT
Cookbook from O'Reilly.

Use Saxon rather than Xalan. Avoid Cocoon.

I've not played with iText, but it is probably better than FOP,
which seems to be floundering. FOP is a memory heavy,
prohibitively so, and it probably shouldn't be by now.

XStream is a great way to generate XML to feed to your XSLT.

Good luck.
 
M

Mladen Adamovic

And I'm already using iText to do PDF in another project, though that one
does not involve XML. XML to PDF searching turns up FOP, can anyone comment
on that? (It looks complicated!)

You can process it into TeX format on the server side and use pdf-latex
(see (1) pdftex on Unix systems) to compile it into pdf to show to user.
 
R

ramesh

Hi Wendy,
We had done something similar. We had to conver xml to pdf using java
based API. We looked at many options and finally narrowed it down to a
product called webisor.

Have a look at http://www.davisor.com/webisor/index.html
Our project is already in production and this product does a decent job
of converting html to pdf. When we tried out the product initially, the
results were not good at all. We just sent a note to their support with
html attached thinking that they would not respond as its a trial
download. they did and finally we ended up buying that.
Ramesh
 
V

Vishal Mehta

I work for a company that has a product that can generate PDF documents
from XML data. The company name is ceTe Software and the name of the
product is DynamicPDF Generator for Java. Following is the link to the
download of fully functional evaluation version
http://www.cete.com/Products/GeneratorForJava/Download.csp. Look at the
Simple XML Report example which shows how to generate PDF documents
from XML data. The examples are downloaded with the product download.

Vishal Mehta
 
R

Richard Wheeldon

Wendy said:
And I'm already using iText to do PDF in another project, though that one
does not involve XML. XML to PDF searching turns up FOP, can anyone comment
on that? (It looks complicated!)

I'm in a similar position and have made the decision to go with XML
output via XSLT to HTML+CSS for web pages and XML to XSL:FO for
giving to FOP to create PDF. The code to get FOP working is pretty
straightforward. Sorting out the XSL:FO markup is easy. Creating
the XSL stylesheets is no harder for XSL:FO than it is for
HTML. Overall, I'd say it's a good way to go. If you get stuck, drop
me a mail,

Richard
 
S

Steve Sobol

Richard said:
I'm in a similar position and have made the decision to go with XML
output via XSLT to HTML+CSS for web pages and XML to XSL:FO for
giving to FOP to create PDF.

That's exactly what I do. Works well. I use one stylesheet for PDF and one for
HTML. Check out http://justthe.net/legal/tos/ - the code that generates the
HTML version of my TOS document is actually PHP and does a straight conversion
using PHP's Sablotron XSLT module, but the code that generates the PDF is a
Java servlet that calls FOP. (I know I could have done it all in Java, but when
I set out to do the PDF code, the rest of the site had already been completed
using PHP.)

You enter your info in the form fields on the PHP page. The servlet actually
looks for certain XML elements and replaces them with the appropriate fields
from the PHP form.

Is it complicated? Yeah, a little, but I'll be happy to give you a copy of my
source code if you want it. ("you" meaning Mr. Wheeldon, or Wendy, or whoever
else is interested.) :)

And once you've done your first app using FOP, the rest will be easy.

The one thing you need to know is that FOP may take several seconds to render a
page. I let people know, on my TOS page on my website, that they won't see a
PDF for about ten to fifteen seconds.

Best,
SJS

--
JustThe.net - Apple Valley, CA - http://JustThe.net/ - 888.480.4NET (4638)
Steven J. Sobol, Geek In Charge / (e-mail address removed) / PGP: 0xE3AE35ED

"The wisdom of a fool won't set you free"
--New Order, "Bizarre Love Triangle"
 
W

Wendy S

Richard Wheeldon said:
I'm in a similar position and have made the decision to go with XML
output via XSLT to HTML+CSS for web pages and XML to XSL:FO for
giving to FOP to create PDF.

That's the direction I'm leaning, too. IText works great in the current
project where all I'm doing is creating a PDF out of a pre-formatted text
report (basically just splitting a long string of text on the page breaks
and feeding it to iText a page at a time.)

But the next project involves a lot of formatting, and my brief forays into
trying to do complicated layout with iText haven't been all that successful.
Besides, I figure I'll add a few more acronyms to my resume this way. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top