我的 html 到 pdf 转换使用 wkhtmlpdf 在没有<style>
标签的情况下工作正常,但是当我包含样式标签时它不起作用,这意味着不生成 pdf 有人帮助我解决这个问题或让我知道如何以这种格式包含我的 style.css .
问问题
181 次
1 回答
0
我的处理方式如下——
<?php
// create some HTML content
$html = '<!DOCTYPE html><html><head>
<style>
body {
margin: 0;
padding: 0;
}
...
</style></head><body>
<!-- Your body content -->
</body></html>';
$options = array(
"no-outline",
"binary" => "/usr/local/bin/wkhtmltopdf",
"margin-top" => ".25in",
"margin-right" => ".25in",
"margin-bottom" => ".55in",
"margin-left" => ".25in",
"zoom" => 1
);
$footer = '<!DOCTYPE html><html><head></head><body>...</body></html>';
$page_options = array('footer-html' => $footer);
$pdf->addPage($html, $page_options);
$pdf->saveAs('MY_PDF_NAME.pdf');
希望这可以帮助!
最好的,
-匆忙
于 2017-06-06T11:19:16.877 回答