16 Dec 2016

html -> PDF conversion in PHP - class / service recommendations?

I'm looking to convert html into pdf in my php code and have been trying my hand at various classes and services available. What I need to do is convert my simple HTML invoice into a PDF and send it as an attachment. The existing classes seem to be quite complicated and resource heavy (opinion based upon comments from other users).

Do you have any specific recommendations?
Manish Goyal

Manish Goyal

Computer Science
17 Dec 2016
Ignore everything and use wkhtmltopdf

wkhtmltopdf

Wkhtmltopdf is not a php class it is a linux utility, so your server must have it installed

you can use it inside php using exec()

exec(wkhtmltopdf x.html x.pdf");

It is best according to me
17 Dec 2016
Interesting suggestion, @Manish Goyal . I'm wondering if using a php class based solution would be a better option. My requirements are super-basic; I only want a basic CSS+HTML conversion into PDF. No tables and fancy fonts at all.
Manish Goyal

Manish Goyal

Computer Science
17 Dec 2016
In that case DOM PDF is also good, wkhtmltopdf will simply convert html design into pdf as it is without any variation, also there are no issues of memory leak or anything for large html page

Share this content on your social channels -

Only logged in users can reply.