3

Does somebody know if it's possible with Printmaker to provide each page, of the PDF you generate, with a static footer and/or header?

Printmaker makes use of the dompdf library. In the documentation of this library I found that this is supported by the library.

But I cannot find in the Printmaker documentation that you can also use this option with the plugin.

I hope somebody can answer this question.

Or does somebody know a plugin that I can use as an alternative, that does support this?

2

I've not yet tested specifically with Printmaker (only Laravel + Dompdf), but you should be able to add page numbers by using a special <script> block in the template you use for PDF rendering. This block's PHP instructions will be interpreted by Dompdf as it renders your document, so you can position additional elements like page numbers, headers/footers, etc.

Example of what you'd include in your Twig template:

<script type='text/php'>
if ( isset($pdf) ) {
    $font = $fontMetrics->get_font('Proxima Nova', 'normal');
    $size = 9;
    $y = $pdf->get_height() - 32;
    $x = ($pdf->get_width() / 2) - ($fontMetrics->get_text_width('1 of 1', $font, $size) / 2);
    $pdf->page_text($x, $y, '{PAGE_NUM} of {PAGE_COUNT}', $font, $size);
}
</script>

More on the subject where I first learned about it: https://stackoverflow.com/a/13184208/897279


CRITICAL POINT:

Ensure PHP is enabled in config/printmaker.php...

'isPhpEnabled' => true,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.