Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Convert html to PDF with dompdf using PHP.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 492
    Comment on it

    Hello Readers , 

    Below is the explanation of how we can create any HTML into PDF and then further send it to emails as an attachment etc.

    Install the Dompdf library from github and then put it into your project.

    With Dompdf downloaded, let’s write a short example that will generate a simple PDF.

    set_include_path(get_include_path() . PATH_SEPARATOR . "/path/to/dompdf");
    require_once "";
    $dompdf = new DOMPDF();
    $html = <<<'ENDHTML'
      <h1>Hello Dompdf</h1>
    $output = $dompdf->output();
    file_put_contents("/path/to/file.pdf", $output);

    That's it.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: