6 Replies Latest reply on May 12, 2009 3:45 PM by mdesignz

    Render Seam PDF template from database

    mdesignz

      Use Case:
      User selects one or more Seam PDF templates (xhtml files containing Seam PDF tags) which are stored in a database.  The files are rendered and the resultant pdf is displayed or saved.


      I can do everything except render a Seam PDF template that resides in the database rather than some local file under WEB-INF (e.g., renderer.render(/template.xhtml).  Any suggestions on taking a byte array that contains the PDF template, and rendering it?


      Thanks.

        • 1. Re: Render Seam PDF template from database
          swd847

          This is probably not easy. Faclets allows you to implement a ResourceResolver to resolve templates, however this only returns a URL.


          I think that if you create your own URL protocol handler you could create a custom databaseTemple:// protocol with a handler that looks them up from a database. Coupled with a ResourceResolver to create these URLs, you should be able to achieve the desired effect. I have never done this so it is just speculation, but it seems feasible.

          • 2. Re: Render Seam PDF template from database
            nickarls

            When you are talking about PDF templates, do you mean fill-in-form templates?

            • 3. Re: Render Seam PDF template from database
              mdesignz

              Unfortunately not.  I have hundreds of those.  This is a separate category of documents that are mostly dynamic in nature (i.e., not a form that just needs values plugged in).

              • 4. Re: Render Seam PDF template from database
                mdesignz

                I'll look into your suggestion and see what I can do.   Thanks.

                • 5. Re: Render Seam PDF template from database
                  nickarls

                  I'm still a bit lost (I don't use PDF support that much); Where does the template come in? You have PDF documents in the database, then you want to do something with them(?) before displaying them?

                  • 6. Re: Render Seam PDF template from database
                    mdesignz

                    I have a couple scenarios.  Hundreds of existing PDFs that I have turned into fillable PDFs using iText and PDFBox.  These fillable forms live in a database and Apache Jackrabbit.  They get retrieved, filled and sent on their way.  The other situation is a document that has fields, a lot of free form text, and several conditional elements.  Using a fillable form in this case doesn't work well because the format is rather fixed.  Creating this second type of form using the Seam PDF tags works really well, but having to place this template somewhere in the context path makes it difficult to deploy.  Having them as an available dynamic resource in a database or repository fits my case much better, and I basically handle them like the fillable PDFs already in the repository.  So the idea would be to retrieve them, render them, and then save or dispatch the resultant file.  Based on Stuart's suggestion, I've started to look at the ResourceResolver, and I found this http://seamframework.org/Documentation/HowDoILoadAFaceletsViewTemplateFromASharedJAR
                    which may be a good starting point.  Thanks again for everyone's suggestions.