Features
- FontAwesome Icons
- Adding Fonts
- Formatters
- Headers and Footers
- HTML Debugging
- LATTE Template Engine
- Page Dimensions
- Preview Features
- Using Stylesheets
- Using Templates
Requirements
PHP>=8.1ProcessWire>=3.0.205RockFrontend>=3.8.2Less- FontAwesome Icons
Using Templates
You want to add some fancy backgrounds to your PDFs? Sure!
/** @var RockPdf $pdf */
$pdf = $modules->get('RockPdf');
$pdf
->setDocTemplate("/site/bg.pdf")
->load("/site/test.php")
->save(preview: true);
In this example we have a template file with one page and we have a final document with one page. That's not always the case.
Continue
By default mPDF will use the last page of your template as background for all following pages in your document. That makes it possible to use a different background for the cover page and use some generic footer for all following pages. If your template has only one page itself then all pages will use the same background:
You can disable adding of the same background over and over again with the second parameter of the setDocTemplate
method:
/** @var RockPdf $pdf */
$pdf = $modules->get('RockPdf');
$pdf
->setDocTemplate("/site/bg.pdf", false)
->load("/site/test.php")
->save(preview: true);