简体   繁体   English

使用mPDF将网页转换为PDF

[英]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. 我搜寻了stackoverflow和其他网站,尽我最大的努力使它正常工作,但无济于事。 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. 这是我的问题,当用户单击按钮时,我试图将网页转换为可打印/可通过电子邮件发送的PDF。 I have already installed mPDF on my server, and here is the code I'm using on my 'pdf_test.php' page 我已经在服务器上安装了mPDF,这是我在“ pdf_test.php”页面上使用的代码

    <?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 mpdf下载链接

        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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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