1 2 3 4 Previous Next 46 Replies Latest reply on Mar 4, 2016 11:17 PM by evan pan

    iText (PDF) support in Seam

    Norman Richards Master

      Seam 1.1.1 has the first iteration of our iText support for PDF generation. Now that it is out in the wild, I'd really appreciate feedback from the community on what you like and don't like. There are a lot of directions we can go with this, so feedback is GREATLY appreciated.

      I would greatly welcome some community involvement in this part of Seam. If you have an interest in document generation, get in touch. There is plenty of room for more hands on this, and the best way to make sure that it solves your problems is to roll up your sleeves and write some code.

        • 1. Re: iText (PDF) support in Seam
          Michael Schuetz Newbie

          As I already mentioned in a former post I am not quite happy with the way Seam generates the extension for the generated pdf-file.

          Is it possible that Seam would redirect to a "simple" pdf-file? The name of the pdf-file could be defined in the link from the content-page.

          For example:

          mypage.xhtml

          ...
          <s:link value="/pdf.jsf" pdfName="myPdf" />
          
          or even better
          
          <s:pdf value="/pdf.jsf" pdfName="myPdf" />
          
          or maybe
          
          <p:link value="/pdf.jsf" pdfName="myPdf" />
          


          pdf.xhtml
          <p:document xmlns:p="http://jboss.com/products/seam/pdf"
           title="Hello">
           <p:paragraph>Hello #{user.name}!</p:paragraph>
          </p:document>
          


          and the generated file would be: /myPdf.pdf

          What's your opinion about that - or would it cause problems with accessing seam components?

          • 2. Re: iText (PDF) support in Seam
            Venkatesh BR Newbie

            Does the current version support embedding digital signatures in pdf or signing a pdf file with a digital signature. If i am not wrong you can do this in iText through the use of pdfStamper. This feature would be used in all e-business sites and it would be really great to have this feature supported through seam.

            • 3. Re: iText (PDF) support in Seam
              Norman Richards Master

              I've added some preliminary support for using file extensions with PDFs.

              components.xml:

               <pdf:documentStore useExtensions="true" />
              


              web.xml:
               <filter>
               <filter-name>Seam Servlet Filter</filter-name>
               <filter-class>org.jboss.seam.servlet.SeamServletFilter</filter-class>
               </filter>
              
               <filter-mapping>
               <filter-name>Seam Servlet Filter</filter-name>
               <url-pattern>*.pdf</url-pattern>
               </filter-mapping>
              
               <servlet>
               <servlet-name>Document Store Servlet</servlet-name>
               <servlet-class>org.jboss.seam.pdf.DocumentStoreServlet</servlet-class>
               </servlet>
              
               <servlet-mapping>
               <servlet-name>Document Store Servlet</servlet-name>
               <url-pattern>*.pdf</url-pattern>
               </servlet-mapping>
              


              A PDF URL would have the form /seam-doc.pdf. I'll add support for /yourViewId.pdf soon. It's just getting a bit late...

              My only concerns are the configuration overhead and the fact that doing it like this prevents you from serving a plain PDF out of your web-app. (obviously you can get around that by being more clever with the URL pattern, but that adds yet MORE configuration overhead)



              • 4. Re: iText (PDF) support in Seam
                Norman Richards Master

                Hmmm - digital signatures are an interesting idea. I hadn't given it much thought. iText does support the feature, so it's definitely a possibility. Would you be willing to open a JIRA feature request for it? If it gets a few votes, I'll definitely bump it up on the priority list.


                • 5. Re: iText (PDF) support in Seam
                  Ronald van Kuijk Master

                  http://jira.jboss.org/jira/browse/JBSEAM-678 (ventateshbr did it, it already has one vote in one day... :-))

                  • 6. Re: iText (PDF) support in Seam
                    Richard Brooks Newbie

                    Let me start off by saying it looks really good.

                    My aim when I tried this out was to create adhoc PDF versions of tabular data in a generic fashion, and came across the following questions and issues:

                    - unlike in html, table columns must have their width explicitly set, is there a way around this or will I need to write some text size calculation routines in order to display it nicely

                    - how can I format the cell data ? in xhtml I use an h:outputText with a nested converter tag for numbers and dates but I can't do that within the pdf tags

                    - I would also like to be able to specify landscape page orientation to fit more columns on the page (prefereably at the chapter/section level rather than the whole document)

                    More general points
                    - The phase listener only appears to catch pdfs launched from pages in the root of the webapp as it checks for startsWith "/seam-doc"

                    - As others have mentioned I would also like to be able to use a different file ending to .seam and would like to be able to use various names for the pdf, ideally on a per document basis (I haven't tried the servlet version in cvs yet)

                    - lastly, the sessional document store doesn't appear to be ever cleared of the pdf data so will fill up the session with data. I'd be tempted to remove the data from the store after it has been sent down to the client (losing the ability to refresh the pdf without going back to the link that generated it), and/or using a store that has a cache expiry timeout

                    Next thing I was going to try is a seam-gen style template for my entities so they can be printed nicely as PDF for people who like paper

                    thanks

                    • 7. Re: iText (PDF) support in Seam
                      Norman Richards Master

                      Thanks. If you have any specific requirements for the functionality or suggestions on how to make it work, please add them to the task.

                      • 8. Re: iText (PDF) support in Seam
                        Norman Richards Master

                        As best as I can tell, iText will not compute column widths for you. You need to determine your column structure in advance. Keep in mind that in iText, the table begins rendering to the PDF long before the end of the table is reached. (allowing for long multi-page tables)

                        You are right. I actually thought I added a renderer for h:outputText, but looking back I see I only added one for literal text. I'll try and get that sometime this weekend.

                        You can specify any page size, but looking through the itext page sizes, I see there are no constants for lanscape mode. I've added pageSize="width height" and orientation="landscape|portrait" to deal with this.

                        I didn't realize I left the DocumentStore in the session. Woops. That should be a conversational component.

                        • 9. Re: iText (PDF) support in Seam
                          Richard Brooks Newbie

                          for the page orientation, there is an example on the lowagie site, its called landscapeportrait on page

                          http://itextdocs.lowagie.com/tutorial/#part1

                          the code is at

                          http://itextdocs.lowagie.com/examples/com/lowagie/examples/general/LandscapePortrait.java

                          it seems to use a convenient rotate method on the page size class

                          • 10. Re: iText (PDF) support in Seam
                            Richard Brooks Newbie

                            thanks for the response, I'll probably end up doing a simple guesstimate of column width ratios based on the heading row and the first row of data using a custom EL function

                            However, in order to use it I need to be able to set the table attributes for widths and columns using an EL expression. It doesn't like it at the moment, I presume thats what the getValueBinding is used for on some of the other attributes

                            • 11. Re: iText (PDF) support in Seam
                              Norman Richards Master

                              Sorry - the lack of a value binding was just oversight on my part. I think in general most people will want to statically size their tables, but I'll be glad to work with to make sure you have whatever you need to dynamically size them. Let me know if you run into any particular problems.

                              • 12. Re: iText (PDF) support in Seam
                                Norman Richards Master

                                Oh and, I did add the width valuebinding in CVS.

                                • 13. Re: iText (PDF) support in Seam
                                  Luiz Augusto Ruiz Newbie

                                  It's great!
                                  My suggestion is to add to an archive taglib.tld for integration with IDEs

                                  • 14. Re: iText (PDF) support in Seam
                                    Luiz Augusto Ruiz Newbie

                                     

                                    - As others have mentioned I would also like to be able to use a different file ending to .seam and would like to be able to use various names for the pdf, ideally on a per document basis (I haven't tried the servlet version in cvs yet)


                                    The p:document tag could have an attribute 'fileName'.

                                    1 2 3 4 Previous Next