5 Replies Latest reply on Mar 20, 2007 11:23 PM by Norman Richards

    Displaying existing PDF files

    Ralph Perko Newbie

      Hello,

      I wish to display an existing PDF file that is dynamically retrieved from a web service at run time. The file is available to me first as a byte array which I write to a temporary file.

      What is the best way to display this in Seam? Can I use the DocumentStore to manage this? I have seen a lot of information on creating PDF files but not handling existing ones.

      I am currently sticking the PDF file into a temporary directory in my WAR and directly linking to it. Is there a better way to do this in Seam?

      Thank you.

        • 1. Re: Displaying existing PDF files
          Norman Richards Master

          The document store component is meant for dynamic content. It is conversational, so anything in the document store goes away when the conversation ends. If that works for you, the document store would be a great option.

          If your content has a longer lifespan or applies to more than one user, you might take a look at hooking directly into ResourceServlet instead.

          • 2. Re: Displaying existing PDF files
            Tony Herstell Master

            I used content servlet used in the seamspace example.

            I ship out images through this.

            I cant see why you couldn't use it to ship out .pdf.

            Can someone point to an example "hooking directly into ResourceServlet instead" as I wouldbe interested in moving over to this method if it preferred.

            • 3. Re: Displaying existing PDF files
              Norman Richards Master

              Look at any of the classes that implement AbstractResource.

              • 4. Re: Displaying existing PDF files
                Ralph Perko Newbie

                Thanks for the reply.

                Can you elaborate on the document store? I have searched through the examples and only find the DocumentStore being accessed in components.xml and via the various <p: tags - none of which accept a "filename" parameter that I saw.

                Should I access the conversationally scoped documentStore reference in my Java code and make an entry by calling documentStore.saveDate() and manually create the DocumentData object?

                How would i then access it on the front-end?

                Or am I not on the right track here?

                Thank you.

                • 5. Re: Displaying existing PDF files
                  Norman Richards Master

                  Yes, you should be able to just put the bytes directly into the document store using saveData(). DocumentStore was not really designed with other apps in mind, so it's usage is not documented anywhere. You should look at how it is used in the pdf code to get a feel whether or not it is helpful.

                  Of course, writing a servlet to dump the data out is pretty simple too. Maybe that is the path of least resistance?