douchun5969 2016-02-07 15:57
浏览 79

html2pdf在pdf中放入一个带有问号的空白页面

I try to make a pdf out of html. I use the following code.

require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {

     ob_start();
     include dirname(__FILE__).'/res/experiment.php';
     $content = ob_get_clean();
     $html2pdf = new html2pdf('P','A4','fr');
     $html2pdf->pdf->SetDisplayMode('fullpage');
     $html2pdf->writeHTML($content);
     $html2pdf->Output('experiment.pdf');
} catch (Html2PdfException $e) {
    $formatter = new ExceptionFormatter($e);
    echo $formatter->getHtmlMessage();
}

The experiment.php is as follows.

    <page>
        <p>First page</p>
    </page>
    <page>
        <p>Second page</p>    
    </page>

As a result I get a blank page with a question mark at the beginning, followed by the expected different First page and Second page.

How to avoid the blank page. Is the question mark on it some kind of error notification. It happens if only experiment.php is UTF-8 encoded. If it is encoded as ansi everything is ok. But I need UTF-8 as my text to convert to pdf uses cyrillic.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 关于#python#的问题:自动化测试