简体   繁体   中英

Converting webpage to Pdf using mPDF

so I'm pretty much losing my mind over here. I have scoured stackoverflow and other sites trying my hardest to get this to work, but to no avail. I just keep getting a blank page. Here is my problem, I am trying to convert a webpage to a printable/emailable PDF when the user clicks a button. I have already installed mPDF on my server, and here is the code I'm using on my 'pdf_test.php' page

    <?php


include("http://s-designco.com/gordon/mpdf60/mpdf.php");

ob_start();

$html = '
<h1><a name="top"></a>mPDF</h1>
<h2>Basic HTML Example</h2>
This file demonstrates most of the HTML elements.
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
';

$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->Output('example.pdf');
?>

I have no clue why this doesn't work. Any help I can get is greatly appreciated! Thank you!

mpdf download link

        ob_start();
        $html = '
        <h1><a name="top"></a>mPDF</h1>
        <h2>Basic HTML Example</h2>
        This file demonstrates most of the HTML elements.
        <h3>Heading 3</h3>
        <h4>Heading 4</h4>
        <h5>Heading 5</h5>
        <h6>Heading 6</h6>
        ';

        $mpdf = new \Mpdf\Mpdf();
        $mpdf->WriteHTML($html);
        $mpdf->Output();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM