8 Replies Latest reply on Jul 10, 2009 4:34 PM by mtorres

    Why Seam PDF?

    grandtourer

      I've been struggling to achieve a high quality PDF output with Seam’s PDF extensions. I have created reasonable quality documents using XSL-FO. I then wondered why Seam needed to invent a whole new tag library in order to render PDF. Surely, XML-FO with EL expression integration using apache's FOP engine would provide an industry standard, fully featured PDF rendering.


      Coding would be similar to existing PDF:


      <s:xsl-fo xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:s="http://jboss.com/products/seam/xsl-fo">
      <fo:root>
           <fo:layout-master-set>
                <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm">
                     <fo:region-body margin="0.5cm"/>
                </fo:simple-page-master>
           </fo:layout-master-set>
              .
              .
      </s:xsl-fo>
      



      Would anyone else be interested in an XSL-FO renderer in Seam?

        • 1. Re: Why Seam PDF?
          norman

          Yes, I consider iText (and the seam wrapper) to be primarily useful for low to medium quality PDF generation, and we've always been very clear about that. 


          On the issue of FO, I don't think FO is something you can expect people to create by hand.  It only seems usable as an intermediate form between some more domain-specific XML and PDF. 


          But, if you think it would be useful, I'm sure you wouldn't be the only one.

          • 2. Re: Why Seam PDF?
            www.supernovasoftware.com

            I use JasperReports to make PDFs currently, but I was going to try Seam PDF today coincidentally.


            1.  What do you mean by low to medium quality PDF generation?
            2.  What would be the option for high quality PDF generation?
            3.  What would high quality PDF generation provide that Seam does not?

            • 3. Re: Why Seam PDF?
              grandtourer

              Seam PDF does not give great control over table layout, borders, margins, padding etc. I’m not sure if I agree with the previous post about XSL-FO being difficult to create by hand. It is similar enough to HTML that people would quickly pick it up. I agree that it has primarily been used transforming XML to XSL-FO and then PDF, but in that use-case the XSL-FO still needs to hand crafted. I was suggesting that instead of doing an XSLT transformation the XSL-FO could be rendered using Facelets and EL expressions. This has the advantage that PDF documents could be built using Facelet fragments (for reuse) and EL expressions would permit access to Seam beans in the current context. The disadvantage of using JasperReports is the need to access the database separately from the Seam context.

              • 4. Re: Why Seam PDF?
                norman

                I don't think iText is capable of doing the things an expensive PDF authoring package can.  I think the way to go with iText is to design a base PDF with a PDF tool and to use iText to write the custom content over it.  If your target is to produce invoices and simple reports, iText is sufficient, though it's important to keep in mind that we don't expose the full power of iText in our integration.

                • 5. Re: Why Seam PDF?
                  www.supernovasoftware.com

                  My goal is to produce invoice, bills of lading, ...


                  JasperReports works fine, but you are correct.  I have to preload my objects and pass them in to Jasper.


                  It uses itext as well and does not expose the full features either.


                  I do agree with the idea of using a PDF authoring tool and then using iText or Seam PDF for the overlay.


                  That is mainly what I am using JasperReports for via iReport designer.


                  I think I will have my graphics artist make me a PDF template and see how that works out.

                  • 6. Re: Why Seam PDF?
                    kukeltje.ronald.jbpm.org

                    Jason Long wrote on Jan 14, 2009 00:41:


                    I do agree with the idea of using a PDF authoring tool and then using iText or Seam PDF for the overlay.



                    I've done this once, about 1.5 years ago in a local seam source tree. I could not keep up at that time with changes in the build system etc... so I stopped wworking on it. It was not that hard however. I introduced two new tags. One for overlaying text, one for images. Not sure if I still have the code, I'll try to find it and post it somewhere (e.g. in a jira issue).


                    Another thing I'll probably be trying out is using 'flyingsaucer', the Sun project for rendering html to pdf and implement it as a servlet filter. I've already seen an article where they do that and it works, at least in general. Not sure how all jsf components come out, especially the dynamic ones

                    • 7. Re: Why Seam PDF?
                      mtorres

                      I too wondered if an integration was possible with fop. I implemented a component that does so as a proof of concept for a project I'm working on, and usage is pretty similar to what you're describing:



                      <rfc:fopDocument
                      xmlns:rfc="http://ourURL/tags"
                      >
                        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
                          ...
                        </fo:root>
                      </rfc:fopDocument>



                      ui:repeat/s:fragment/el expressions can be used to control rendering/data.


                      I was able to get the documents in fop examples folder to render, at least those that I tested(images.fo, tables.fo, extensive.fo). Let me know if you're interested.


                      It does seem to be a good feature to have within seam.

                      • 8. Re: Why Seam PDF?
                        mtorres

                        Just wanted to say that so far, using fo for document generation has been working well. Using Office2FO project from sourceforge, which are xslts to convert openoffice documents to fo, we are able to compose openoffice documents marked up with el, and export them to fo in openoffice.