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

Kaustubh Katdare

Kaustubh Katdare

@thebigk Oct 26, 2024
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?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Dec 16, 2016

    Ignore everything and use wkhtmltopdf

    <a href="https://wkhtmltopdf.org/" target="_blank" rel="nofollow noopener noreferrer">wkhtmltopdf</a>

    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
  • Kaustubh Katdare

    Kaustubh Katdare

    @thebigk Dec 16, 2016

    Interesting suggestion, #-Link-Snipped-# . 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

    @manish-r2Hoep Dec 16, 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