Movatterモバイル変換


[0]ホーム

URL:


mPDF Manual – mPDF functions

ImportPage() (until 8.0)

(mPDF ≥ 2.3 && mPDF < 8.0)

ImportPage – Import a page from an external PDF file

Note: This method was superseded byimportPage() in mPDF 8.0.

Description

intImportPage (int$pageno[, float$crop_x[, float$crop_y[, float$crop_w[, float$crop_h[, string$boxname ]]]]])

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

$pageno

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

Default:1

$crop_x

Specifies the x-coordinate (abscissa) for the page of the source PDF file, when importing a ‘cropped’ page into the template.Value in millimetres.

Default:0

$crop_y

Specifies the y-coordinate (ordinate) for the page of the source PDF file, when importing a ‘cropped’ page into the template.Value in millimetres.

Default:0

$crop_w

Specifies the width in millimetres when importing a ‘cropped’ page into the template.

Default:null uses the full page width from the source file

$crop_h

Specifies the height in millimetres when importing a ‘cropped’ page into the template.

Default:null uses the full page height from the source file

$boxname

$boxname is currently not used.

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
2.3Function was added.

Examples

Example #1 - Using a full page

<?php// Require composer autoloadrequire_once__DIR__.'/vendor/autoload.php';$mpdf=new\Mpdf\Mpdf();$mpdf->SetImportUse();// only with mPDF <8.0$pagecount=$mpdf->SetSourceFile('logoheader.pdf');$tplId=$mpdf->ImportPage($pagecount);$mpdf->UseTemplate($tplId);$mpdf->WriteHTML('Hello World');$mpdf->Output();

Changelog

VersionDescription
8.0Function was replaced byimportPage().

Example #2 - Using a ‘cropped’ page

<?php// Require composer autoloadrequire_once__DIR__.'/vendor/autoload.php';$mpdf=new\Mpdf\Mpdf();$mpdf->SetImportUse();// only with mPDF <8.0$pagecount=$mpdf->SetSourceFile('testfile.pdf');$tplId=$mpdf->ImportPage($pagecount,50,50,100,100);$mpdf->UseTemplate($tplId,'','',100,100);$mpdf->Output();

See Also


[8]ページ先頭

©2009-2026 Movatter.jp