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>
そして、このファイルは 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");
}
?>
dompdf_config.inc.php で DOMPDF_ENABLE_PHP を true に設定しましたが、レンダリングされた PDF にテスト文字列またはページ数が表示されます。なんで?
ここに私の小さな例を圧縮しました: http://uploads.dennismadsen.com/pdf.zip
さらに情報が必要な場合は教えてください。