Hi everyone.
I inserted the script into my custom template (bootstrap copy) to display the number of pages with the total pages.
But I have a strange effect
On the first and subsequent pages, page 1 of 5 is shown with all page numbers superimposed.
Page 2 of 5
and so on.
The numbers on the left then the current page is displayed correctly except the number on the right.
Until on the last page it is displayed correctly
See image
What have I done:
I inserted the script in the default.php file below the line:
defined('_JEXEC') or die('Restricted access');
In the css_custom file I adjusted this:
but I can't understand the problem. I also tried changing various dompdf versions.
I obviously activated php in the pdf by adding this in the pdf.php file
$options->set("isPhpEnabled", true);
from an online search I found this which is the same problem.
But I didn't understand how to correct the same in the template.
stackoverflow fix
Has anyone had the same problem? or do you know how to fix this?
In fabrik 3 it worked for me.
Thank you
I inserted the script into my custom template (bootstrap copy) to display the number of pages with the total pages.
But I have a strange effect
On the first and subsequent pages, page 1 of 5 is shown with all page numbers superimposed.
Page 2 of 5
and so on.
The numbers on the left then the current page is displayed correctly except the number on the right.
Until on the last page it is displayed correctly
See image
What have I done:
I inserted the script in the default.php file below the line:
defined('_JEXEC') or die('Restricted access');
Code:
?>
<div id="footdompdf">
<script type="text/php">
if ( isset($pdf) ) {
$size = 6;
$color = array(0,0,0);
if (class_exists('Font_Metrics')) {
$font = Font_Metrics::get_font("helvetica");
$text_height = Font_Metrics::get_font_height($font, $size);
$width = Font_Metrics::get_text_width("Page 1 of 2", $font, $size);
} elseif (class_exists('Dompdf\\FontMetrics')) {
$font = $fontMetrics->getFont("helvetica");
$text_height = $fontMetrics->getFontHeight($font, $size);
$width = $fontMetrics->getTextWidth("Page 1 of 2", $font, $size);
}
$foot = $pdf->open_object();
$w = $pdf->get_width();
$h = $pdf->get_height();
// Draw a line along the bottom
$y = $h - $text_height - 24;
$pdf->line(16, $y, $w - 16, $y, $color, 0.5);
$pdf->close_object();
$pdf->add_object($foot, "all");
$text = "Pagina {PAGE_NUM} di {PAGE_COUNT}";
// Center the text
$pdf->page_text($w / 2 - $width / 2, $y, $text, $font, $size, $color);
}
</script>
</div>
In the css_custom file I adjusted this:
Code:
body {margin-top:1.5em;margin-bottom:1.5em}
#footdompdf {
display:block;
position: fixed;
bottom: 0px;
width:100%;
height: 1.1em;
I obviously activated php in the pdf by adding this in the pdf.php file
$options->set("isPhpEnabled", true);
from an online search I found this which is the same problem.
But I didn't understand how to correct the same in the template.
stackoverflow fix
Has anyone had the same problem? or do you know how to fix this?
In fabrik 3 it worked for me.
Thank you