2 Replies Latest reply on May 24, 2011 2:54 PM by laerciooliveira

    How to convert HTML with CSS inline to PDF?

    laerciooliveira
      Staff need to get a report that an HTML that comes in the form of a String of bank and convert it to PDF. I'm using the tag for that <p:html> css but loses all formatting. Anyone know how to keep the formatting?
      Below my code:

      <p:paragraph>
          <p:html>
            <h:outputText value="#{classHome.getHtml()}" escape="true"  />
          </p:html>
      </p:paragraph>
        • 1. Re: How to convert HTML with CSS inline to PDF?
          lvdberg

          Hi,


          The library used by Seam can do a lot for you, but don't expect that it is able to transfer a complete html-view to a 100% correct PDF-view. If it comes from anoher site (that's what I understand), just render it in an IFRAME and put a print button in the surrounding frame. In that way you use the renderer of your OS which render and prints the page for you. You can even install a PDF-Writer which taks care of printing it to PDF.


          Leo 

          • 2. Re: How to convert HTML with CSS inline to PDF?
            laerciooliveira

            Leo van den Berg wrote on May 24, 2011 09:29:


            Hi,

            The library used by Seam can do a lot for you, but don't expect that it is able to transfer a complete html-view to a 100% correct PDF-view. If it comes from anoher site (that's what I understand), just render it in an IFRAME and put a print button in the surrounding frame. In that way you use the renderer of your OS which render and prints the page for you. You can even install a PDF-Writer which taks care of printing it to PDF.

            Leo 



            The problem is that document is a HTML stored on database. We use an HTML editor to save/edit the documents. With this approach we can show the document easily on the application but now we need generate a PDF with the content file.


            Can someone suggest a solution for this? Do you recommend another Java API to do this?


            Thank you in advance.