【发布时间】:2015-12-26 15:41:41
【问题描述】:
我正在尝试使用 mpdf 将我的 html 页面转换为 pdf 格式。问题是我无法将多个 css 应用于 pdf 文件..这是我的php代码
<?php
$html =file_get_contents('mpdf/test.html');
include("../mpdf.php");
$mpdf=new mPDF();
$mpdf->SetDisplayMode('fullpage','two');
// LOAD a stylesheet 1
$stylesheet = file_get_contents('assets/css/main.css');
$mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text
// LOAD a stylesheet 2
$stylesheetextra = file_get_contents('assets/css/test.css');
$mpdf->WriteHTML($stylesheetextra ,1); // The parameter 1 tells that this is css/style only and no body/html/text
$mpdf->WriteHTML($html,2);
$mpdf->Output();
exit;
?>
它提供的输出不附带 test.css 。 main.css 正确应用于 pdf 文件,但 test.css 没有应用。请 帮我? 提前谢谢你
【问题讨论】:
-
确实将第二个样式表附加到第一个工作,即 $stylesheet = file_get_contents('assets/css/main.css') 。 file_get_contents('assets/css/test.css'); $mpdf->WriteHTML($stylesheet,1);