3 Replies Latest reply on Sep 7, 2010 3:49 AM by Aboo salimon

    Save pdf into database using seam itext

    Prajwal Boloor Newbie

      Hi All,

      I have been using seam itext to generate pdf files using itext jsf tags.
      Now I have to save the generated pdf file as a blob in database.

      how can i use the existing xhtml file with the jsf itext tags and store the generated pdf on the database.

      any help on this

      Thanks in advance

        • 1. Re: Save pdf into database using seam itext
          Shervin Asgari Master

          This is possible. You need to render the faces page. More information here

                  private byte[] createPDF(String path) {
                          // String DATA_STORE =
                          // "org.jboss.seam.document.documentStore.dataStore";
                          EmptyFacesContext emptyFacesContext = new EmptyFacesContext();
                          // Context conversation = Contexts.getConversationContext();
                          byte[] bytes = null;
                          try {
                                  Renderer.instance().render(path + "/status/status_pdf.xh
                                  DocumentStore doc = DocumentStore.instance();
                                  if (doc != null) {
                                          DocumentData data = doc.getDocumentData("1");
                                          ByteArrayDocumentData byteData = null;
                                          if (data instanceof ByteArrayDocumentData) {
                                                  byteData = (ByteArrayDocumentData) data;
                                          } else {
                                                  throw new Exception("Couldnt get the byt
          es from the pdf document, unkown class " + data.getClass().getName());
                                          bytes = byteData.getData();
                          } catch (Exception ex) {
                                  log.error("Error when trying to get the content of the p
          df in bytes with the message #0", ex.getMessage());
                          } finally {
                          return bytes;

          This is how we do it

          • 2. Re: Save pdf into database using seam itext

            I've been trying to put this solution to work but has no luck so far as Render.instance().render(viewID) throws

            java.lang.IllegalArgumentException: resource doesn't exist: tempTagReceiptPdf.xhtml

            This PDF enabled xhtml file is available under

            and used various ways to pass this view id but did not help.

            Could you please tell me what I should pass view id for the above path. By the way the app name is EZPass

            Thanks in advance.

            • 3. Re: Save pdf into database using seam itext
              Aboo salimon Newbie

              even  i am getting same error can seam experts help this.???