- Posts: 16
- Thank you received: 0
Technical discuss
Display Total pages in dompdf
- bluetooth
- [bluetooth]
-
Topic Author
- Offline
- New Member
-
Less
More
09 Oct 2024 20:39 - 09 Oct 2024 20:40 #202
by bluetooth
New Topic
Link
Ha, I managed to display the total pages.
1. You must hack libraries\fabrik\fabrik\Helpers\Pdf.php - function iniDomPdf: around line 140 add $options->set("isPhpEnabled", true);
2. In your custom PDF list template's default.php (with some fixed header/footer) add e.g.
Code:
This will output "2 of 10" at the absolute position set by $x, $y.
It doesn't matter if you put it in the header or footer, as far as I understand it must be only inside a div that is displayed on every page.
Maybe we can add a textfield for additional PDF options in list layout settings.
Ha, I managed to display the total pages.
1. You must hack libraries\fabrik\fabrik\Helpers\Pdf.php - function iniDomPdf: around line 140 add $options->set("isPhpEnabled", true);
2. In your custom PDF list template's default.php (with some fixed header/footer) add e.g.
Code:
Code:
<div id="footdompdf">
<script type="text/php">
if ( isset($pdf) ) {
$font = $fontMetrics->get_font("Arial, Helvetica, sans-serif", "normal");
$size = 12;
$pageText = $PAGE_NUM . "of" . $PAGE_COUNT;
$y = $pdf->get_height() - 24;
$x = $pdf->get_width() - 15 - $fontMetrics->get_text_width($pageText, $font, $size);
$pdf->text($x,$y, $pageText, $font, $size);
}
</script>
It doesn't matter if you put it in the header or footer, as far as I understand it must be only inside a div that is displayed on every page.
Maybe we can add a textfield for additional PDF options in list layout settings.
Last edit: 09 Oct 2024 20:40 by bluetooth.
Please Log in or Create an account to join the conversation.