【问题标题】:Try to add css in mpdf. But not accept anyhow尝试在 mpdf 中添加 css。但无论如何也不接受
【发布时间】:2017-01-29 07:39:16
【问题描述】:

我尝试在mpdfstyletables.css 文件中添加 css,但无法添加新 css。 PHP 代码:

<?php

$html = utf8_decode($html);
$html = iconv("UTF-8","UTF-8//IGNORE",$html);
include("./MPDF/mpdf.php");
$tpdf=new mPDF('c','A4','','',32,25,27,25,16,13); 
$tpdf->ignore_invalid_utf8 = true;
$stylesheet = file_get_contents('mpdfstyletables.css');
$tpdf->WriteHTML($stylesheet,1);
$tpdf->WriteHTML($html,2);
$tpdf->Output($fname,'I');
exit();
?>

我尝试过this,但对我不起作用。

如何添加 CSS。我感谢所有的回应。提前谢谢。

【问题讨论】:

  • css 文件里有什么?您发布的代码应该可以正常工作。
  • 会不会因为您将其写入没有标签的 html 而失败?

标签: php css mpdf


【解决方案1】:

你可以尝试渲染 html 内容而不是 utf8_decode。

即,

 $tpdf->WriteHTML(("youtfilename.php")->render(),2);

通过这样使用,我已经应用了两个 css 文件,并且工作正常。

希望对您有所帮助!

【讨论】:

    猜你喜欢
    • 2013-03-09
    • 2015-12-26
    • 2022-11-20
    • 1970-01-01
    • 2021-05-09
    • 1970-01-01
    • 1970-01-01
    • 2019-05-10
    • 1970-01-01
    相关资源
    最近更新 更多