mPDF Manual – Setting PDF file properties

Document Metadata

A PDF file contains metadata about the title, author, subject, creation date, keywords. The title is usually shown in the top of the screen when a user views the file; the rest of the metadata can be accessed by viewing Document properties in Adobe Reader.

You can set the metadata directly using:

Metadata is also set automatically if you pass full HTML code to WriteHTML() including:

  • title is read from <title>...</title> tags
  • subject, keywords and author are read from <meta ... /> tags

Whichever is set later will override previous settings.

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.

Example
<?php

$mpdf = new mPDF();

$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('
Hallo World
');

$mpdf->Output();

?>

See Also