The itext support was designed to be the simplest possible thing that works while still being extremely easy to extend to support more itext concepts. I've been extending it according to user requests, but it's mostly been in maintenance mode for the last few releases. The next big change I will make is to try and remove the troubling redirect. The options are limited since facelets tragically doesn't support non-text output, but I think I can render the template in the background and return the PDF to the user immediately.
I'd love to improve the header/footer support as you suggest. Right now it's a real pain because what itext is doing here is really inconvenient. I you have any code, just open up a JIRA issue, and I'll work with you to get it in.
I am using Jasper Reports for PDF generation. Are that any plans to integrate Jasper Reports or some other reporting engine into to Seam?
I do appreciate the quartz integration. :)
Ah thanks for the response. Indeed what iText is doing here pretty inconvenient. This makes me wonder why the choice for iText, besides being quite popular? Speed?
Jasper or Apache FOP could be candidates as well.
my current approach is slightly hackish. Using a facet with a name 'header' allows to get to the PdfWriter / Document before it gets opened. I was thinking about something along the lines of having a pageEvents tag with event tags as childs. Eg:
<facet name="header"> <p:pageEvents> <event name="onEndPage"> ... </event> </p:pageEvents> </facet>
At the moment I end up with a wrapper around PdfPageEvent (if I remember correctly) which allows to 'register' events by adding it to a hashmap. But to be honest, it does not feel really nice and I am juggling with classes.
I've moved away from the tags for complex PDFs and started using existing PDFs as templates and then writing data into them (acrofields) and over them (using getOverContent) and then PdfStamping them as new PDFs. You end up with something that looks very good while not having to write that much code. You are also able to get a designer to create the PDF (eg. an invoice) in a way that would be rather difficult with iText.
That's more of the model I'd like to move towards. I feel iText (and all the pdf generators really) are only suited for medium quality output. If you want high quality output, I think using a template from a high-quality PDF tool is the best way to go.
If I find the time, I'll update my locally created tags to seam 2.0 and post them. I made tags that take an existing pdf and can do either:
- fill in forms based on acrofield names
- do overlay based on x,y coordinates in combination with a pagenumber
It works kinda great, but never found the time to update it and really test it. There is a jira issue for this afaik where I'll attach the code I have
How flexible is PDF stamping? Is it possible for example to extend tables or leave parts out if they are not needed? Are there opensource tools that are able to generate these templates?
@kukeltje: if you could attach your not cleaned up stuff others might be able to fix that.
If you don't have Adobe Acrobat you can create a PDF with whatever tool (eg Word [worstcase]) and then add the acrofields with iText itself to create a template.
You can do anything with the stamping/overlay. It's very flexible. I'm adding a table and also a rotated watermark.
@kukeltje: your tags sound cool. Would love to see them.