Movatterモバイル変換


[0]ホーム

URL:


mPDF Manual – mPDF functions

importPage() (since 8.0)

(mPDF ≥ 8.0)

importPage – Import a page from an external PDF file

Description

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.

Parameters

$pageNumber

This parameter specifies the page number from the source PDF file to import. $pageNumber shouldbe a positive integer value.

Default:1

$box

The page boundary to import. Default set to\setasign\Fpdi\PdfReader\PageBoundaries::CROP_BOX.

Default:\setasign\Fpdi\PdfReader\PageBoundaries::CROP_BOX

$groupXObject

Define the form XObject as a group XObject to support transparency (if used).

Default:true

Return Value

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()

Changelog

VersionDescription
8.0Function was added.

Examples

Example #1 - Using a full page

<?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();

Example #2 - Using a ‘cropped’ page

<?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();

See Also


[8]ページ先頭

©2009-2026 Movatter.jp