Accessing mpdf function in CakePdf

I’ve got working pdf plugin, where I can write something into template file and it appears in pdf file, but I want to access mPdf function https://mpdf.github.io/reference/mpdf-functions/overview.html like addPage() and I don’t know how.
In controller:

this->autoRender = false;
		Configure::write('CakePdf', [
				'engine' => 'CakePdf.Mpdf',
				'margin' => [
					'bottom' => 15,
					'left' => 15,
					'right' => 15,
					'top' => 15
				],
				'orientation' => 'portrait',
				
			]);
			
		$sciezka = TMP."karta.pdf";
		$CakePdf = new \CakePdf\Pdf\CakePdf();
		$CakePdf->template('karty',null);		
		$pdf = $CakePdf->write($sciezka);

My template file karty.ctp where I want to use those functions:

<?php $this->layout = false;

?>
Test 2
<?php
$this->addPage();
?>
Page 2

but how access them? $this->addPage(); doesn’t work (undefined function).

It looks to me like there may not be a way to do that. :frowning: The CakePdf class instantiates an “Engine”, but that’s a plugin-specific wrapper. And in the output function of the mPDF engine, it creates an mPDF object, uses it (setting only the orientation, encoding, page size and HTML to convert), and returns the contents of the resulting PDF as a string. Nothing in there that would give you access.

You could presumably create your own engine to feed to the CakePdf configuration, which implements more of that kind of functionality, and access it through $CakePdf->engine()->xxx()?

Thanks for quick answer. I look into source yesterday night (or today night :wink: ) and got similar conclusion.
I tried putting “custom html tags” like:

<htmlpageheader name="MyHeader1">Something</htmlpageheader>
<sethtmlpageheader name="MyHeader1" value="on" show-this-page="1" />

described here https://mpdf.github.io/headers-footers/method-4.html but header doesn’t appear.
What is interesting, when name tag differ between this two, mPdf emits notice so it must understand it somehow.
Probably I will skip settings headers for this one, and someday I will try mPdf more direct way - $mpdf = new \mPDF(); like is in /vendor/firendsofcake/cakepdf/src/Pdf/Engine/MpdfEngine.php