mPDF Manual – mPDF functions

SetSourceFile() (until 8.0)

(mPDF ≥ 2.3 && mPDF < 8.0)

SetSourceFile – Specify the source PDF file used to import pages into the document

Description

int SetSourceFile ( string $file )

Specify the source PDF file used to import pages into the document.

Parameters

$file

This parameter specifies the source PDF file used to import pages into the document.

Note$file should be a relative path to a local file.

Return Value

SetSourceFile() returns the number of pages in the source file.

Changelog

Version Description
2.3 Function was added.
8.0 Function was removed in favour of setSourceFile().

Examples

Example #1

<?php

// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();

// Enable imports
$mpdf->SetImportUse();

// Specify a PDF template
$pagecount = $mpdf->SetSourceFile('logoheader.pdf');

// Import the last page of the source PDF file
$tplId = $mpdf->ImportPage($pagecount);
$mpdf->UseTemplate($tplId);

$mpdf->WriteHTML('Hello World');
$mpdf->Output();

See Also

Fork me on GitHub