新闻报导

How can I get the total number of pages in DOMPDF?

  • btt
  • [btt]
  • Topic Author
  • Offline
  • Administrator
  • Administrator
More
22 Jul 2024 01:02 - 22 Jul 2024 01:04 #191 by btt
New Topic

Since 

Code:
dompdf
 
Code:
0.7.0
, the 
Code:
dompdf_config.inc.php
 file has been removed (and is no longer referenced): all dompdf options should be set at run time.

This means you have to create a new instance of 
Code:
Options
 class
Code:
$domPdfOptions = new Options();
And then you may enable PHP inline using the following line
Code:
$domPdfOptions->set("isPhpEnabled", true);
The rest of the codes are correct and will show a page number and page count
Code:
<script type="text/php"> if (isset($pdf)) { $x = 72; $y = 18; $text = "{PAGE_NUM} of {PAGE_COUNT}"; $font = $fontMetrics->get_font("helvetica", "bold"); $size = 6; $color = array(255,0,0); $word_space = 0.0; // default $char_space = 0.0; // default $angle = 0.0; // default $pdf->page_text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle); } </script>
Update As pointed out by @london-smith, this also works for DomPDF 0.8.1
Link
Fabrikar
This seems to work
stackoverflow.com/a/41767053

So hack:
in libraries\fabrik\fabrik\fabrik\Helpers\Pdf.php line 143 add
$options->set("isPhpEnabled", true);

and put the "script" part into your template's default.php
Last edit: 22 Jul 2024 01:04 by btt.

Please Log in or Create an account to join the conversation.