我有DOMPDF的问题.我正在运行PHP 5.3.3并拥有最新的DOMPDF 0.6.0 beta2.
我已经创建了这个HTML模板:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Printed document</title>
</head>
<body>
<script type="text/php">
echo "test";
if ( isset($pdf) ) {
echo $PAGE_NUM;
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这个文件用于呈现PDF:
<?php
require_once("dompdf/dompdf_config.inc.php");
$templateFile = 'template.html';
$content = file_get_contents($templateFile);
if ($content !== false) {
$dompdf = new DOMPDF();
$dompdf->load_html($content);
$dompdf->render();
$dompdf->stream("test.pdf");
}
?>
Run Code Online (Sandbox Code Playgroud)
在dompdf_config.inc.php中,我将DOMPDF_ENABLE_PHP设置为true,但仍然在我呈现的PDF中显示测试字符串或页数.为什么?
我在这里压缩了我的小例子:http: //uploads.dennismadsen.com/pdf.zip
如果您需要更多信息,请告诉我.