Convert php page to pdf on the fly

13,608

I has some success with HTML2PDF, give it a try. Example:

$content = get_include_contents('/resume.php');

require_once(dirname(__FILE__).'/html2pdf/html2pdf.class.php');
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->WriteHTML($content);
$html2pdf->Output('example.pdf');
Share:
13,608
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    Possible Duplicate:
    Convert HTML + CSS to PDF with PHP?

    I want to convert page like this http://alexking.org/projects/html-resume-template/demo/resume.php to pdf on the fly by a link inside the page, I tried dompdf but failed to have the result.

  • Arnaud Le Blanc
    Arnaud Le Blanc over 12 years
    It's a PDF generator, it doesn't take HTML/CSS as input
  • Arnaud Le Blanc
    Arnaud Le Blanc over 12 years
    It's a PDF generator, it doesn't take HTML/CSS as input
  • Arnaud Le Blanc
    Arnaud Le Blanc over 12 years
    It's a PDF generator, it doesn't take HTML/CSS as input
  • Admin
    Admin over 12 years
    if resume.php page on my root, how I can use this to convert the the page resume.php from another php file?
  • matino
    matino over 12 years
    Call it as you want but it's able to solve the problem...
  • ldiqual
    ldiqual over 12 years
    See my edited answer for an example.
  • Rebecca
    Rebecca almost 11 years
    TCPDF is very good but it's writeHTML() functionality is limited. It doesn't do a great job with tables for example and ignores CSS. I found wkhtmltopdf and Snappy (github.com/KnpLabs/snappy) to be a lot better.