6 Replies Latest reply on Jun 3, 2008 10:33 PM by norman

    Saving SEAM PDF as a file on the server?

    flynn

      Good Afternoon, All:


      I am looking for code examples that will allow me to use SEAM to generate PDF files that I can save to the server instead of rendering to a web browser.


      In brief, when the user has completed a process of entering data on the website, I would like to generate a PDF that I can store on the file server. (This PDF will eventually be printed and stuffed in an envelope along with appropriate pamphlets and other data, to be snail mailed to the user in response to their online request.)


      It appears that the ability to generate PDF files in SEAM that can be saved to a server instead of being sent to a browser is a future enhancement for SEAM. In the meantime, I need a solution more immediately.


      Has there been any code developed that can handle this type of request until this is added as a new feature in a future release of SEAM?


      If no code exists, if anyone has any suggestions that I could pursue in developing my own code to meet this need, please feel free to offer your advice here.


      With Regards,
      Jason Flynn Kemp

        • 1. Re: Saving SEAM PDF as a file on the server?
          felipealbertao

          Hello Jason,


          I never did that myself, but one suggestion is to check Seam's source code to find out how the Renderer component actually renders content (Renderer is used to send emails -- see Seam docu ch 17). I just checked it myself, and actually it doesn't look too complicated. Check the file jboss-seam-2.0.1.GA/ui/src/main/java/org/jboss/seam/ui/facelet/FaceletsRenderer.java


          You probably could use it as an example on how to render something to a file. Line 104 shows how you could pass a FileWriter.


          Or... it seems like you will process those PDFs in batch, so another suggestion is to create a simple script that uses wget to fetch the PDF from a given URL and store it in a given directory. It's definitely not a pretty solution, but it might work for you. Alternatively, you could use some Java-based HTTP client to accomplish the same.

          • 2. Re: Saving SEAM PDF as a file on the server?
            bravocharlie.seam.signup.benny.me.uk

            Hi Jason,


            See my post here!


            Cheers- Ben

            • 3. Re: Saving SEAM PDF as a file on the server?
              flynn

              Ben Catherall wrote on Jun 03, 2008 11:56:


              Hi Jason,

              See my post here!

              Cheers- Ben


              Ben,


              In reviewing your code, I can see that the first section stands alone as its own class. I assume that I will need to add the appropriate imports, but the basics are there.


              Now, as for the second section of code, I assume that this (or something like it) could be added to my manager bean for the processing of these requests after the user submits their information via the web UI. Using the PDF XHTML file I've created, this code will presumably generate the PDF and store it as a byte array under the variable named data. We cast it as a byte array into the bytes variable, and presumably from there, I can save the file to the server from the bytes variable.


              Do I understand that correctly? Or is there more to this picture that I'm missing?


              With Regards,
              Jason Flynn Kemp

              • 4. Re: Saving SEAM PDF as a file on the server?
                bravocharlie.seam.signup.benny.me.uk

                You got it :)

                • 5. Re: Saving SEAM PDF as a file on the server?
                  flynn

                  Now, if I could only get conversation to resolve, I'd be happy. I thought it was implicitly called out in Seam as a variable, but for whatever reason, Eclipse doesn't recognize it so it isn't compiling. :(


                  I'm still digging away at it, though,
                  Jason

                  • 6. Re: Saving SEAM PDF as a file on the server?
                    norman

                    There's an open JIRA, JBSEAM-2613, for this. If anyone has specific suggestions or usecases, it might be helpful to comment there.