Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: HTML to PDF conversion

  1. #1
    Join Date
    Aug 2004
    Location
    New York
    Posts
    168

    Default HTML to PDF conversion

    My front end designers created a great looking html front end. This front end is pretty complex containing lots of images and CSS. One of my project requirements is to be able to export this front end to PDF. The PDF has to be pretty much an exact copy of the HTML version. I was looking at the AbstractPdfView examples and they seem to be pretty manual. I doubt I could manually recreate this great looking html front end using itext, although it's a great tool. If I already have the finished HTML, is there an easy way to create a PDF version? Thx.

    -karl

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Good question. Spring's PDF support isn't designed to do this. But there must be a library out there somewhere...
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Posts
    203

    Default

    There is htmltopdf library, but it don't work with complex html

    regards

  4. #4
    Join Date
    Dec 2004
    Posts
    2

    Default Re: HTML to PDF conversion

    Hello kbaum,
    I'd like to know where did you find the example of AbstractPdfView, because 'till now I've just found API at this link: http://www.springframework.org/docs/...ctPdfView.html.
    Thanks in advance,
    Claudia
    Quote Originally Posted by kbaum
    ... I was looking at the AbstractPdfView examples and they seem to be pretty manual. ...
    -karl

  5. #5
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    Can't think of a magic answer to this, but if you used the Apache FOP toolkit, you might do the following:

    1. Translate your CSS into an importable XML document containing xsl:attribute-set elements. This would then mirror your existing style.css.

    e.g.

    myStyle { font-weight: bold; }

    vs

    <xsl:attribute-set name="myStyle">
    <xsl:attribute name="font-weight">bold</xsl:attribute>
    </xsl:attribute-set>


    2. Maybe use some front end technology that allowed you to get at the rendered HTML, i.e. JSP is likely out, but Velocity might work since you could programmatically render the HTML into some buffer so you could subsequently process it into an XML-FO document , and then into a PDF. You may even have to cleanup the rendered HTML before trying to convert it into an XSL-FO document, i.e. make it well-formed, handle special characters.

    If you can't find a magic answer, then depending on how much XSLT/PDF building you've done, I'd also suggest you look at using the Apache FOP toolkit to build a single PDF document so you fully understand the gap between laying out HTML and PDF document -- so that you can be sure it's just not easier to build each PDF separately/manually from it's HTML version.

  6. #6
    Join Date
    Dec 2004
    Posts
    17

    Default Html->pdf

    Hey karl!

    not sure if you are still looking, but:


    I cant vouch for any of these, but check out the links on:

    http://www.w3.org/Style/CSS/


    there are a bunch(including a servlet) that should work (one even passes the ACID test)

  7. #7
    Join Date
    Jun 2006
    Location
    outside boston
    Posts
    108

    Default pdf possibilites

    Perhaps you are only looking for free software to do what you ask and/or software integrated with your app, however I just thought I'd mention that the Adobe Acrobat product really is great for this kind of thing. I've used it before to create a pdf copy of a site I wanted to perserve - you basically point it to a starting page and tell it how many levels to retrieve and it does - creating linked pdf. Of course you need more than the reader to do this.
    Anyway, just thought I'd mention it.

  8. #8
    Join Date
    Mar 2007
    Posts
    1

    Default

    PDF to HTML - Converts PDF files to HTML files while seeking to preserve the original page layout (as best as technically possible).

  9. #9
    Join Date
    Mar 2006
    Location
    Turku, Finland
    Posts
    93

    Default

    If you are at the XHTML level (e.g JSF/Facelets), then the integration from there on could be done as

    http://today.java.net/pub/a/today/20...-renderer.html

    It is problably simple to integrate in other frameworks, too. Although you should be aware that there is no 1:1 mapping between rendered HTML and e.g PDF.

  10. #10

    Default

    Given 5million times I would use iText over anything else on any given day.

Similar Threads

  1. Replies: 4
    Last Post: Jun 20th, 2005, 01:36 AM
  2. Replies: 0
    Last Post: Jun 17th, 2005, 02:53 AM
  3. Replies: 1
    Last Post: May 23rd, 2005, 02:56 PM
  4. Replies: 0
    Last Post: Mar 8th, 2005, 10:00 PM
  5. servlet-mapping and html questions
    By cesar in forum Web
    Replies: 0
    Last Post: Sep 22nd, 2004, 05:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •