Results 1 to 29 of 29

Thread: html to pdf

  1. #1
    Join Date
    Mar 2004
    Posts
    1,301

    html to pdf

    Is there any good application that you recommend for converting from html to pdf. I am looking for one using PHP.

    Thanks!

  2. #2
    Join Date
    Aug 2004
    Location
    AU
    Posts
    690

  3. #3
    Join Date
    Aug 2003
    Location
    Chicago, IL USA
    Posts
    2,781
    Quote Originally Posted by TRIBOLIS View Post
    Didn't read the thread, did we?


    Anyhow, take a look at http://php.net/manual/en/ref.pdf.php
    CloudRck.com - Host on Cloudrck
    Unmetered VPS Solutions at it's finest

  4. #4
    Join Date
    Aug 2004
    Location
    AU
    Posts
    690
    Oops, I was quickly paste the link off my fav bookmark after quick read his post. (I thought he means html with php coding converts to PDF).

  5. #5
    Join Date
    Feb 2003
    Location
    Canada
    Posts
    958
    I've tried this application in my Ruby apps and it works great.
    http://www.princexml.com/

    A little bit pricey, but renders HTML/CSS properly, which is generally a problem with other html->pdf applications.

    You could interface to it with PHP without any difficulty.

  6. #6
    Join Date
    Sep 2004
    Location
    Chennai , India
    Posts
    4,608
    Quote Originally Posted by Adam-AEC View Post
    I've tried this application in my Ruby apps and it works great.
    http://www.princexml.com/

    A little bit pricey, but renders HTML/CSS properly, which is generally a problem with other html->pdf applications.

    You could interface to it with PHP without any difficulty.
    Thanx for the product! My friend was looking for it, but it costs a bit high

  7. #7
    Join Date
    Feb 2007
    Location
    Ukraine, Lviv
    Posts
    149
    How about dompdf? Link: http://www.digitaljunkies.ca/dompdf/

    Another thing is fpdf (http://www.fpdf.org/) but I have never used it

  8. #8
    phpclasses.org has some decent classes for this, however I am unsure if they are php4 or php5

    link
    Omada Site Incorporated
    Jeremy Wilson, President & Technology Officer
    Please feel free to contact me on Instant Messenger

  9. #9
    Join Date
    Aug 2004
    Location
    Shanghai
    Posts
    1,449
    I use fpdf, it's just great and easy.

    There's only one thing that I didn't find yet how to do: how to setup the filename and force a "save as" thing. Anybody knows?

    Thomas
    GPLHost:>_ open source hosting worldwide (I'm founder, CEO & official Debian Developer)
    Servers & our leading control panel and our Xen VPS hosting, which are already included in Debian and Ubuntu
    Available in: Kuala Lumpur, Singapore, Sydney, Seattle, Atlanta, Paris, London, Barcelona, Zurich, Israel

  10. #10
    Join Date
    Oct 2001
    Posts
    114
    Quick note: he asked how to convert "html to pdf", not for generic PDF output routines.

    There are two commonly used packages for this purpose; the first is the perl script html2ps, which you can get here:

    http://user.it.uu.se/~jan/html2ps.html

    The second is written entirely in PHP; you can get it here:

    http://www.tufat.com/s_html2ps_html2pdf.htm

    EDIT: You can also try htmldoc, from htmldoc.org.

    If you *are* just looking for a generic way to output PDF, I'd consider pdflatex. Additionally, note that three different ways to output PDFs are covered in my book, Practical Reporting with Ruby and Rails - of course, the example source is in Ruby.

    Take it easy,

    David Berube
    Is your Rails app running slow? I can help. Call me at 603-485-9622.
    http://berubeconsulting.com

  11. #11
    Join Date
    Mar 2004
    Posts
    1,301
    Quote Originally Posted by Form1 View Post
    The second is written entirely in PHP; you can get it here:

    http://www.tufat.com/s_html2ps_html2pdf.htm
    Thanks David! I would test this one out.

    Thanks others too for your great suggestions.

  12. #12
    Join Date
    Jan 2003
    Posts
    308
    Quote Originally Posted by gplhost View Post
    I use fpdf, it's just great and easy.

    There's only one thing that I didn't find yet how to do: how to setup the filename and force a "save as" thing. Anybody knows?

    Thomas
    I haven't used this for a LONG time but I believe you can just add a header like

    Content-disposition: attachment; filename=SaveMe.PDF

  13. #13
    Join Date
    Oct 2001
    Posts
    114
    Quote Originally Posted by mnu View Post
    I haven't used this for a LONG time but I believe you can just add a header like

    Content-disposition: attachment; filename=SaveMe.PDF
    Pretty sure that's correct; if not, it's very close.

    Take it easy,

    David Berube
    Is your Rails app running slow? I can help. Call me at 603-485-9622.
    http://berubeconsulting.com

  14. #14
    Join Date
    Aug 2004
    Location
    Shanghai
    Posts
    1,449
    Quote Originally Posted by Form1 View Post
    Pretty sure that's correct; if not, it's very close.

    Take it easy,

    David Berube
    Of course, I tried this one (before it was suggested here), and it does NOT work, unfortunately.

    Thomas
    GPLHost:>_ open source hosting worldwide (I'm founder, CEO & official Debian Developer)
    Servers & our leading control panel and our Xen VPS hosting, which are already included in Debian and Ubuntu
    Available in: Kuala Lumpur, Singapore, Sydney, Seattle, Atlanta, Paris, London, Barcelona, Zurich, Israel

  15. #15
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    I use DOMPDF and it works wonderfully.

  16. #16
    Join Date
    Mar 2004
    Posts
    1,301
    Quote Originally Posted by Dan L View Post
    I use DOMPDF and it works wonderfully.
    How does it works with tables and CSS?
    Thanks Dan!

  17. Thumbs up

    HTML2PDF is the one I normally use

    Its actually an extension of FPDF

    Both of the above are opensource. Have a search in Google for those

    Regards
    Prabhul
    South Ocean Solutions

  18. #18
    Join Date
    Aug 2001
    Location
    Central USA
    Posts
    200
    Quote Originally Posted by Dan L View Post
    I use DOMPDF and it works wonderfully.
    I used DOMPDF and I had a bunch of serious problems. It says it works with one level of tables, but really it's questionable. I made HTML/CSS invoices and was trying to convert them to PDF on the fly. Not only would it take forever to process, the output was totally jacked on large invoices where the invoice items table spanned multiple pages.

    I tried everything I could think of to get it to work, but in the end had to resort to using FPDF with a few extensions and assemble the invoice with PHP code. Now the invoices generate _VERY_ quickly (even big ones and even on batch process with a bunch of invoices at once), and always look consistent. It's not really the route I wanted to go since now I have two places to make changes on invoices, but it's the only way I could get decent and consistent looking PDF invoices.
    InvoiceMore - Online Billing & Invoicing
    phpDataMapper - Object-Oriented PHP5 Data Mapper ORM

  19. #19
    Join Date
    Oct 2001
    Posts
    114
    Quote Originally Posted by gplhost View Post
    Of course, I tried this one (before it was suggested here), and it does NOT work, unfortunately.

    Thomas
    I'd love to see a situation where it's broken. Can you provide me with an example? I know it doesn't work for some very old versions of IE - some issues on 5.5 SP1, apparently (http://support.microsoft.com/kb/279667).

    I've used this technique on a number of occasions, from Ivy League universities on the east coast to casting commercials in Los Angeles, and I've yet to have any trouble with it.

    Take it easy,

    David Berube
    Is your Rails app running slow? I can help. Call me at 603-485-9622.
    http://berubeconsulting.com

  20. #20
    Join Date
    Aug 2004
    Location
    Shanghai
    Posts
    1,449
    Well, it doesn't work for our open source web hosting control panel, you are free to download the sources and try the invoice thing (see links in my sig.)...

    Thomas
    GPLHost:>_ open source hosting worldwide (I'm founder, CEO & official Debian Developer)
    Servers & our leading control panel and our Xen VPS hosting, which are already included in Debian and Ubuntu
    Available in: Kuala Lumpur, Singapore, Sydney, Seattle, Atlanta, Paris, London, Barcelona, Zurich, Israel

  21. #21
    Join Date
    Oct 2001
    Posts
    114
    I'm actually running DTC on a extra server I have kicking around - I'm going to go take a look.

    UPDATE: I've downloaded the latest DTC generic source, and found only one reference to Content-Disposition, on line 48 of shared/inc/sql/domain_info.php; it looks like this:

    Code:
            header('Content-Disposition: attachment; filename="'.$file_name.'"');
    According to the docs, it should look like this:

    Code:
            header('Content-Disposition: attachment; filename='.$file_name);
    No quotes around the filename.

    Anyway, Microsoft KB has a decent article on the technique:

    http://support.microsoft.com/kb/260519

    Take it easy,

    David Berube
    Last edited by Form1; 04-17-2008 at 12:35 PM.
    Is your Rails app running slow? I can help. Call me at 603-485-9622.
    http://berubeconsulting.com

  22. #22
    Join Date
    Dec 2007
    Location
    Lebanon
    Posts
    413
    I use dompdf and never had a problem!!

  23. #23
    Join Date
    Mar 2004
    Posts
    1,301
    Quote Originally Posted by southoceansolutions View Post
    HTML2PDF is the one I normally use

    Its actually an extension of FPDF

    Both of the above are opensource. Have a search in Google for those

    Regards
    Prabhul
    South Ocean Solutions
    So far, I have got the default sample work great; however, when I used the "sample.simplest.from.memory.php", I got the following errors:


    Notice: Only variable references should be returned by reference in /var/www/hdn/html/html2pdf/css.cache.class.php on line 38

    Notice: Only variables should be assigned by reference in /var/www/hdn/html/html2pdf/dom.activelink.inc.php on line 75

    Do you have any idea? could this due to the php version?
    I am currently using PHP Version 4.4.6-0.dotdeb.2

  24. #24
    Join Date
    Mar 2004
    Posts
    1,301
    Quote Originally Posted by orbitz View Post
    So far, I have got the default sample work great; however, when I used the "sample.simplest.from.memory.php", I got the following errors:


    Notice: Only variable references should be returned by reference in /var/www/hdn/html/html2pdf/css.cache.class.php on line 38

    Notice: Only variables should be assigned by reference in /var/www/hdn/html/html2pdf/dom.activelink.inc.php on line 75

    Do you have any idea? could this due to the php version?
    I am currently using PHP Version 4.4.6-0.dotdeb.2
    I just turned all the error warning off, and get the output pdf file working now.
    /*error_reporting(E_ALL);
    ini_set("display_errors","1");*/
    error_reporting(0);
    ini_set("display_errors","0");

  25. #25
    I use free version CutePDF.It goes through printer.

  26. #26
    Join Date
    Mar 2004
    Posts
    1,301
    Quote Originally Posted by i-net View Post
    I use free version CutePDF.It goes through printer.
    Thanks i-net, but the one you are using is for desktop application. The one that I was looking for, which I have found, is used on a website where a PDF file can be dynamically generated based on data popullated from a database.

  27. #27

    pd4ml

    I use pd4ml.
    it's great.
    it's java-based.
    it's super-cheap (80 Euros).
    it renders yui-grid layouts fine.
    it's easy to interface with php, ruby or whatever server-side language you use.
    it's easy to create your own custom java utility-class, even if you don't know much java, to use use the PD4ML api directly if the default switches don't do it all for you.

    PD4ML

    I wrapped mine in a ruby module and put it in google code here

    Ext on Rails blog -- Implementing Jack Slocum's ExtJS framework in Rails
    Last edited by christocracy; 04-26-2008 at 02:26 AM.

  28. #28
    Join Date
    Feb 2003
    Location
    Connecticut
    Posts
    5,441
    Quote Originally Posted by Czaries View Post
    I used DOMPDF and I had a bunch of serious problems. It says it works with one level of tables, but really it's questionable. I made HTML/CSS invoices and was trying to convert them to PDF on the fly. Not only would it take forever to process, the output was totally jacked on large invoices where the invoice items table spanned multiple pages.

    I tried everything I could think of to get it to work, but in the end had to resort to using FPDF with a few extensions and assemble the invoice with PHP code. Now the invoices generate _VERY_ quickly (even big ones and even on batch process with a bunch of invoices at once), and always look consistent. It's not really the route I wanted to go since now I have two places to make changes on invoices, but it's the only way I could get decent and consistent looking PDF invoices.
    I was lucky that the file I used was relatively simple - otherwise I can certainly see where you'd run into issues.

    For the record, it works with CSS and tables.

  29. #29

    An example of PD4ML

    Here's an example of PD4ML output from my blog

    An Invoice constructed with yui-grid css

    (btw: PD4ML offers a fully-functional demo -- a subtle watermark will be added to footer)
    Last edited by christocracy; 04-26-2008 at 02:44 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
  •