velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Can velocity be used for generating reports in PDF
Date Thu, 16 Oct 2008 21:09:08 GMT
The problem is that the Velocity Engine pushes its output to a Writer (an
argument to the mergeTemplate() method) but iText doesn't include a Writer
class that can be used for the purpose - creating a PDF in iText means
creating a Document object then calling methods of that class to add
"chunk" objects, each of which contains the text along with the font/style
settings that apply to that text. So the Writer class I developed was a
bridge between the Writer interface that Velocity needs, and the call-based
interface that iText uses.

As I mentioned this was a while ago. It's possible that by now the
developers of iText have added a Writer interface that would make things
simpler, and it's also possible that there's a third-party package to do
this. Also bear in mind that iText isn't the only PDF generation package
(the page you linked mentions several) and it's possible that one these has
a Writer that will work with Velocity.

Adrian Tarau <> wrote on 10/16/2008 02:54:48 PM:

> Why not using iText directly (or some other library) to generate PDF?
> Using Velocity to generate PDF is not a good way to go...
> wrote:
> > The way I did this was to have my Velocity templates generate output
> > that was sent to a PDFWriter class that I wrote. This class detected
> > special markers in the input stream that indicated new paragraphs,
> > bold/underline/italic sections, font changes, images etc., and made
> > to iText to create the "chunks" that iText uses and add them to the PDF
> > output document on the fly. It could handle basic stuff (paragraph
> > multiple fonts, tables, background colours and images, embedded images)
> > was adequate for what I needed it for. It couldn't handle more advanced
> > stuff like floating sidebars, but that wasn't something I needed.
> >
> > That was a while ago. If I was going to do the same thing again I'd
> > the Velocity templates produce XML and base the Writer on
> >
> > It's always possible that there is a direct PDF Writer class out there
> > already that accepts input text in some handy form like XML - I just
did a
> > quick Google and didn't find anything, but it's such an obvious thing
> > be surprised if there isn't *something*.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > For additional commands, e-mail:
> >
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message