NYCPHP Meetup

NYPHP.org

[nycphp-talk] html to PDF conversion?

David Roth davidalanroth at gmail.com
Fri Mar 5 11:06:42 EST 2010


Thanks to everyone and John for replying.

I installed wkhtmltopdf on a CentOS 5.4 i386 machine without any  
problem. Just the executable was supplied in the i386 version I  
downloaded and installed.

I found something interesting. I used wget to get the HTML and then  
fed it through wkhtmltopdf. The PDF looked OK, then I noticed in the  
help you can do wkhtmltopdf website.com website.pdf, so I thought why  
not let the program do the whole thing. To my surprise the output  
looked even better! When wkhtmltopdf is getting the web page it  
performs some magic to create the PDF properly.

David Roth

On Mar 5, 2010, at 10:13 AM, John Campbell wrote:

> The best solution I have seen uses webkit create the PDFs.  You get
> pretty much the same results as using the print feature in
> Safari/Chrome.
>
> I don't know if it will run on your system, but it is worth a look:
>
> http://code.google.com/p/wkhtmltopdf/
>
> On Fri, Mar 5, 2010 at 3:07 AM, David Roth <davidalanroth at gmail.com>  
> wrote:
>> The solution doesn't have to be written in PHP, but it's fine if it  
>> is as
>> long as it works.
>>
>> I'm looking for a command-line way to convert HTML to a PDF on  
>> CentOS 5.4,
>> because I need to do this in a shell script to create the webpage  
>> as a .PDF
>> file.
>>
>> I've looked at xhtml2pdf written in Python, but CentOS 5.4 is still  
>> running
>> Python 2.4 and the best I can tell it needs Python 2.5 or later  
>> cause I
>> couldn't get it to work.
>>
>> I also tried PDF-FromHTML-0.31 which is written in PERL, but requires
>> HTML::TIDY which seems to be unavailable currently.
>>
>> Thanks in advance for any advice. If this is now considered trivial  
>> to do in
>> PHP and I've just not stumbled across it yet, please enlighten me.
>>
>> David Roth
>>
>> _______________________________________________
>> New York PHP Users Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> http://www.nyphp.org/Show-Participation
>>
> _______________________________________________
> New York PHP Users Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/Show-Participation




More information about the talk mailing list