mPDF Manual – mPDF functions

# SetDocTemplate()

(mPDF >= 2.3)

SetDocTemplate – Specify an external PDF file to use as a template

## Description

void SetDocTemplate ( [ string $file [, boolean$continue ]])

Specify an external PDF file to use as a template. Each page of the external source PDF file will be used as a template for the corresponding page in your new document. If the current mPDF document has more pages than the external PDF source document, the last page will (optionally) continue to be used for any remaining pages.

## Parameters

$file This parameter specifies the source PDF file used as the template document.$file should be a relative path to a local file.

Default: BLANK

$continue Values: 1 | 0 | true | false If true (or any positive value) it forces the last page of the source file to continue to be used as a template, if the current mPDF document contains more pages than the source file. Default: false ## Changelog Version Description 2.3 Function was added. ## Examples Example #1 <?php // Require composer autoload require_once __DIR__ . '/vendor/autoload.php';$mpdf = new \Mpdf\Mpdf();

$mpdf->SetImportUse();$mpdf->SetDocTemplate('logoheader.pdf',true);

// Do not add page until doc template set, as it is inserted at the start of each page
$mpdf->AddPage();$mpdf->WriteHTML('Hello World');

// Subsequent pages from logoheader.pdf will be inserted on all subsequent pages
\$mpdf->Output();