mPDF Manual – mPDF functions

SetTitle()

(mPDF ≥ 1.0)

SetTitle – Set the document title

Description

void SetTitle ( string $text )

Set the title for the document. The title is displayed at the top of the Adobe Reader screen when viewing the PDF file, and is included in the document metadata, which can be seen when inspecting the document properties in Adobe Reader.

Parameters

$text

Defines the text to appear as a Title. The text should be UTF-8 encoded, but should not contain HTML mark-up tags.

strcode2utf() is a useful function provided with mPDF which converts HTML numerical entities to UTF-8 encoded string.

Examples

Example #1

<?php
$mpdf = new \Mpdf\Mpdf();

$mpdf->SetTitle('My Title');

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

Example #2

<?php
$mpdf = new \Mpdf\Mpdf();

// The library defines a function strcode2utf() to convert htmlentities to UTF-8 encoded text
$md = strcode2utf("&amp;#1575;&amp;#1610;&amp;#1604;&amp;#1575;&amp;#1578; &amp;#1601;&amp;#1610;&amp;#1605;&amp;#1575; &amp;#1575;&amp;#1610;&amp;#1604;&amp;#1575;&amp;#1578; &amp;#1601;&amp;#1610;&amp;#1605;&amp;#1575;");
$mpdf->SetTitle($md);

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

See Also

Fork me on GitHub