8 Replies Latest reply on Nov 19, 2007 7:26 AM by damianharvey

    Complex PDF generation and architecture question

    bolke

      Hello,

      I am wondering who is using Seam's PDF generating features to generate complex PDFs? The background to this question is that the current tag support seems a little simple and not sufficient for the more complex layouts and the current architecture also seems difficult to extend.

      For example I have been looking into rewriting UIHeaderFooter (and siblings) to support for example images. However iText using an event model in case of more complex pages (eg. onEndPage event). The current architecture does not allow this (afaik).

      Now, I understand that this is a feature request and I even like to do some work on it (eg. small patches if I can, my coding skills are not that good), but I would like the rationale behind the architecture so I am able to continue in the same direction.

      So please take no offence, I am pretty new to Seam. I like it a lot and I am looking forward to help extending it.

      regards

        • 1. Re: Complex PDF generation and architecture question

          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.


          • 2. Re: Complex PDF generation and architecture question

            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. :)

            • 3. Re: Complex PDF generation and architecture question
              bolke

              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.



              • 4. Re: Complex PDF generation and architecture question
                damianharvey

                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.

                Cheers,

                Damian.

                • 5. Re: Complex PDF generation and architecture question

                  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.

                  • 6. Re: Complex PDF generation and architecture question
                    kukeltje

                    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

                    • 7. Re: Complex PDF generation and architecture question
                      bolke

                      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.


                      • 8. Re: Complex PDF generation and architecture question
                        damianharvey

                        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.

                        Cheers,

                        Damian