1 2 3 4 Previous Next 46 Replies Latest reply on Mar 4, 2016 11:17 PM by evanpan Go to original post
      • 15. Re: iText (PDF) support in Seam

        I think the goal would be to have the file name the same as the view name. foo.xhtml would be be accessed as foo.seam and redirect to foo.pdf. Given the way documentStore works now, it certainly would be possible to allow arbitrary file names, but I'm not sure we need to be that complicated.

        As for a tld file, that's a JSP thing not a facelets thing. There won't be one until someone writes a JSP taglib for this stuff. I'm hoping that someone won't be me. :)



        • 16. Re: iText (PDF) support in Seam
          spambob

          Hello Norman,

          congratulation on your PDF library!

          While I partially agree that PDF Forms are nice I run in some problems with them (while using iText):

          1. One isn't able to format the label & the inputfield
          2. The input is always displayed in some typewriter font
          (Please correct me if I'm wrong on any of this ;))

          What I would like to have is more like the PDFStamper (if I remember iText correctly).
          I.e. I have a ISO letter and then fill in the content (address, text, ...) by using tags that give me the possiblity to set the margin in X & Y axis, the width, the font, ..., and a footer after I'm done ;)

          This way one could create a PDF with whatever method and latter "stamp" it with the actual content.

          More exactly: extend your current library with a tag that sets the font, exact distance from left & upper paper border, textwidth, ... and perhaps some nice paragraph braking (so that there isn't only a single line on the next page).

          This would really save me some time instead of accessing the content via iText direct writer!

          What do you think of it?

          • 17. Re: iText (PDF) support in Seam

            Just to make sure I am hearing you correctly - you want to take an existing PDF document and define precise rectangles over it in which seam should generate a page overlay, essentially "filling in" the document?

            • 18. Re: iText (PDF) support in Seam

              I've checked in some changes to PDF that solve the session/conversation scope problem and that give significantly more control over the URLs used. (/myApp/myDocument.pdf, for example) I'd appreciate feedback from anyone who was bothered by the previous behavior.

              • 19. Re: iText (PDF) support in Seam

                Hey Norman,
                thanks for your fast implementation.

                I have already tried the new stuff. (web.xml, components.xml changed following your description)

                Following exception occurs when trying to acces /test.pdf:

                11:55:27,193 ERROR [SeamServletFilter] ended request due to exception
                java.lang.NullPointerException
                 at org.jboss.seam.pdf.DocumentStore.dataForId(DocumentStore.java:35)
                 at org.jboss.seam.pdf.DocumentStore$$FastClassByCGLIB$$d513343b.invoke(<generated>)
                 at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                 at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
                 at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.RollbackInterceptor.rollbackIfNecessary(RollbackInterceptor.java:29)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:52)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:39)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.SynchronizationInterceptor.serialize(SynchronizationInterceptor.java:31)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
                 at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:145)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:80)
                 at org.jboss.seam.pdf.DocumentStore$$EnhancerByCGLIB$$a90ba54a.dataForId(<generated>)
                 at org.jboss.seam.pdf.DocumentStoreServlet.doGet(DocumentStoreServlet.java:28)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.seam.servlet.SeamServletFilter.doFilter(SeamServletFilter.java:48)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                 at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                 at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                 at java.lang.Thread.run(Thread.java:595)
                11:55:27,193 ERROR [[Document Store Servlet]] Servlet.service() for servlet Document Store Servlet threw exception
                java.lang.NullPointerException
                 at org.jboss.seam.pdf.DocumentStore.dataForId(DocumentStore.java:35)
                 at org.jboss.seam.pdf.DocumentStore$$FastClassByCGLIB$$d513343b.invoke(<generated>)
                 at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
                 at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:45)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:55)
                 at org.jboss.seam.interceptors.OutcomeInterceptor.interceptOutcome(OutcomeInterceptor.java:21)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.RollbackInterceptor.rollbackIfNecessary(RollbackInterceptor.java:29)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.ConversationInterceptor.endOrBeginLongRunningConversation(ConversationInterceptor.java:52)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:27)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.ExceptionInterceptor.handleExceptions(ExceptionInterceptor.java:39)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.interceptors.SynchronizationInterceptor.serialize(SynchronizationInterceptor.java:31)
                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:585)
                 at org.jboss.seam.util.Reflections.invoke(Reflections.java:18)
                 at org.jboss.seam.intercept.Interceptor.aroundInvoke(Interceptor.java:169)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:64)
                 at org.jboss.seam.intercept.RootInterceptor.createSeamInvocationContext(RootInterceptor.java:144)
                 at org.jboss.seam.intercept.RootInterceptor.invokeInContexts(RootInterceptor.java:129)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:102)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:145)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.intercept(JavaBeanInterceptor.java:80)
                 at org.jboss.seam.pdf.DocumentStore$$EnhancerByCGLIB$$a90ba54a.dataForId(<generated>)
                 at org.jboss.seam.pdf.DocumentStoreServlet.doGet(DocumentStoreServlet.java:28)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
                 at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.seam.servlet.SeamServletFilter.doFilter(SeamServletFilter.java:48)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                 at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
                 at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                 at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                 at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                 at java.lang.Thread.run(Thread.java:595)



                Did I miss something?

                Ah, one more thing: when accessing pdf with /test.jsf all p:tags seams to be ignored and simple html-page is shown.

                Michael


                • 20. Re: iText (PDF) support in Seam

                  You still need to access the page as test.seam - it will redirect to test.pdf if you are using the docstore servlet. Does the seam-document example work?

                  • 21. Re: iText (PDF) support in Seam
                    rbz285

                    I've tried out the latest (3 hours ago) version from cvs and it works well for me. I used the servlet version so it gives me a url with my.pdf in it (once I remembered to put the useExtensions value in components.xml).

                    I tried my generic table again (thanks for the value binding on the widths property) but it still needs a value binding on the columns property before it'll work. I tested the concept by quickly subclassing the UITable tag to do it and it again works well (as does the landscape mode)

                    I've just voted for http://jira.jboss.com/jira/browse/JBSEAM-680 for the formatting of values.

                    I've got one other request, I'd like to be able to have headers and footers on the first page as well as all the others.

                    On the NPE reported by m.schuetz above, I can also get it whenever the PDF doesn't exist in the store, which can happen if the user hasn't logged in, manually types the url, or if there was just an error in the xhtml so the generation failed. Not sure the best thing for it to do in these cases, maybe send a 404 ?

                    • 22. Re: iText (PDF) support in Seam

                      I don't know how to get headers and footers on the first page. iText doesn't seem to support it, but I may just not know the magic incantation. I w

                      I'm adding error code for the missing PDF case as we speak.

                      For things like the missing valuebindings, please just open JIRA issues so they don't get lost. (no need for this one - I've just fixed it and will check it in shortly)


                      • 23. Re: iText (PDF) support in Seam

                        I don't know how to get headers and footers on the first page. iText doesn't seem to support it, but I may just not know the magic incantation. I w

                        I'm adding error code for the missing PDF case as we speak.

                        For things like the missing valuebindings, please just open JIRA issues so they don't get lost. (no need for this one - I've just fixed it and will check it in shortly)


                        • 24. Re: iText (PDF) support in Seam
                          rbz285

                          thanks

                          There's a comment at the top of the javadoc for the lowagie Document class

                          (I saw it at http://www.docjar.com/docs/api/com/lowagie/text/Document.html)

                          When you change the header/footer on a certain page, this will be effective starting on the next page.


                          and the example below seems to imply that if the header and footer are set on the Document object prior to calling open() then they will appear on the page. I haven't tested it though

                          However, given the nested nature of the PDF tags I'm not sure how you'd discover the header/footer tags in the encodeBegin of the Document tag... unless you can delay opening the document until the first non-header/footer tag is added to it

                          • 25. Re: iText (PDF) support in Seam

                            When I was first doing the headers, I tried to use newPage to increment the page count and apply the headers, but I wasn't able to make it work. Putting it before document.open() does work.

                            I'll see what I can do. I might need to move header and footer into facets. I'm probably going to revisit this at some point soon because I really do not like the extremely limited page number support. You really cannot do interesting headers that way.

                            • 26. Re: iText (PDF) support in Seam
                              spambob

                               

                              "norman.richards@jboss.com" wrote:
                              Just to make sure I am hearing you correctly - you want to take an existing PDF document and define precise rectangles over it in which seam should generate a page overlay, essentially "filling in" the document?

                              Exactly! This way I could create a PDF Template with Acrobat, Scribus or any other DTP Software and later fill in the content with PDFStamper at some - in the JSF file - defined positions.

                              My problem is that the simple iText way is nice to generate a "quick & dirty" PDF report but to get something "professional" looking I need more control - i.e. exact positioning of the address so it can be seen through the envelope.

                              It would save me a lot of time if i could simply say put that text there in that font and ... instead of working with PdfContentByte. And my Customers could get their bills online which would look exactly like the ones I send them per mail (cause I would use the same PDF ;)).

                              Regarding your problem with header, footer & page numbers you perhaps should have a look at http://itextdocs.lowagie.com/tutorial/directcontent/pageevents/. The idea is to react upon page events and use templates for stuff like "Page 4 of x". When the end of the document is reached you just replace x with the page count and it will be set on every page. Similar way with headers & footers. Hope this helps.

                              • 27. Re: iText (PDF) support in Seam

                                Just as an update, I've add p:text, which allows the use of a converter on a field.

                                • 28. Re: iText (PDF) support in Seam
                                  rbz285

                                  thanks, works well for me

                                  • 29. Re: iText (PDF) support in Seam

                                    I've added some very basic signature support in CVS. I'm quite comfortable with the crypto side of things, so I won't have any problem fixing that up. However, I'm not entirely clear what the normal use cases for signed PDFs would be. I've never seen a signed PDF in the wild. I'd appreciate it if some of you guys requesting this feature would take a look and give me some feedback.