mPDF Manual – mPDF functions

SetSourceFile()

(mPDF >= 2.3)

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

VersionDescription
2.3 Function was added.

Examples

Example #1

<?php

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

$mpdf = new mPDF();

$mpdf->SetImportUse();

$pagecount = $mpdf->SetSourceFile('logoheader.pdf');

// Import the last page of the source PDF file

$tplId = $mpdf->ImportPage($pagecount);

$mpdf->UseTemplate($tplId);

$mpdf->WriteHTML('Hallo World');

$mpdf->Output();

?>

See Also