(mPDF ≥ 8.0)
importPage – Import a page from an external PDF file
intimportPage (int$pageNumber[, string$box[, bool$groupXObject ]]])
Import a page, or part of a page, from an external PDF file. The external source file must first be setwithsetSourceFile(). A ‘template’is created in mPDF which stores the image of this page, ready to insert into the document.
This parameter specifies the page number from the source PDF file to import. $pageNumber shouldbe a positive integer value.
Default:1
The page boundary to import. Default set to\setasign\Fpdi\PdfReader\PageBoundaries::CROP_BOX.
Default:\setasign\Fpdi\PdfReader\PageBoundaries::CROP_BOX
Define the form XObject as a group XObject to support transparency (if used).
Default:true
importPage() returns an ID for the template which it has created. This ID can be used at any time to insert the templateinto the document withuseTemplate()orSetPageTemplate()
| Version | Description |
|---|---|
| 8.0 | Function was added. |
<?php// Require composer autoloadrequire_once__DIR__.'/vendor/autoload.php';$mpdf=new\Mpdf\Mpdf();$pagecount=$mpdf->setSourceFile('logoheader.pdf');$tplId=$mpdf->importPage($pagecount);$mpdf->useTemplate($tplId);$mpdf->WriteHTML('Hello World');$mpdf->Output();<?php// Require composer autoloadrequire_once__DIR__.'/vendor/autoload.php';$mpdf=new\Mpdf\Mpdf();$pagecount=$mpdf->setSourceFile('testfile.pdf');$tplId=$mpdf->importPage($pagecount);$mpdf->useTemplate($tplId,50,50,100,100);$mpdf->Output();