【发布时间】:2014-04-07 07:16:39
【问题描述】:
我想给我的字符串一个颜色,但是 dompdf 不允许我。这是我的 html 代码:
<style type="text/css">
.red{
color:#574595;
}
</style>
<div style="color:#574595;">asdfsdfsd</div><br>
<font color="red">TRALALAL</font><br>
<div class="red">TRALALAL</div><br>
我尝试了 3 种可能的方法,但都不起作用。我该如何管理? 这是我的完整代码:
<?php
ini_set("gd.jpeg_ignore_warning", 1);
set_include_path(get_include_path() . PATH_SEPARATOR . "dompdf");
require_once('dompdf/dompdf_config.inc.php');
$category = $_GET['c'];
$dompdf = new DOMPDF();
$html =
'<html>
<head>
<style type="text/css">
.red{
color:#574595;
}
</style>
</head>
<body>
<div style="color:#574595;">asdfsdfsd</div><br>
<font color="red">TRALALAL</font><br>
<div class="red">TRALALAL</div><br>
</body>
</html>';
$dompdf->load_html($html);
$dompdf->render();
$output = $dompdf->output();
file_put_contents("pdf_generated/file.pdf", $output);
header("Location: http://acros.netlogiq.info/pdf_generated/file.pdf");
?>
结果如下:
【问题讨论】:
-
有人帮我解决这个问题吗?
-
没有与修改颜色工作方式相关的设置。您的示例应该可以正常工作。您使用的是什么版本的 dompdf? PHP版本?您是否收到任何 PHP 警告、通知或错误(如果没有,请尝试
ini_set('display_errors',true);)?