您好我正在使用 DOMPDF 生成 PDF 文件,我想知道如何获取页码。
我在 DOMPDF 的常见问题页面中提到了以下内容。并且没有成功。注意:我也打开了内联 PHP 以及它在常见问题解答中提到的
以下是我的代码
<?php
require_once("dompdf/dompdf_config.inc.php");
ob_start();
//be sure this file exists, and works outside of web context etc.)
$dompdf = new DOMPDF();
$html=" <script type='text/php'>";
if ( isset($pdf) ) {
$font = Font_Metrics::get_font("yourfont", "normal");
$size = 9;
$y = $pdf->get_height() - 24;
$x = $pdf->get_width() - 15 - Font_Metrics::get_text_width("1/1", $font, $size);
$pdf->page_text($x, $y, "{PAGE_NUM}/{PAGE_COUNT}", $font, $size);
}
$html.=" </script>";
$html .="
aaaaa<br/>aaaaaa<br/>aaaaaa<br/>aaaaa<br/>aaaaaa<br/>aaaaaa<br/>aaaa<br/>aaaaa<br/>aaaaaa<br/>aaaaa<br/>
aaaaa<br/>aaaaaaa<br/>aaaaaa<br/>
aaaaa<br/>aaaaaa<br/>
aaaaaaa<br/>aaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>
aaaaaaa<br/>aaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>
aaaaaaaa<br/>aaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>
aaaaaaaa<br/>aaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>
aaaaaaaa<br/>aaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>
aaaaaaaaa<br/>aaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>
aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>aaaaaaaaaaaaaaaaa<br/>
</body></html>";
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");
?>
有人可以指出我这个问题吗?我在哪里做错了