Guides › mPDF › Document metadata

Document metadata

Written for mPDF 8.2 on PHP 8.1+. Updated 2 November 2026.

Metadata is the information a PDF carries about itself. Viewers show the title in the window bar, search engines and document systems index it, and screen readers announce it.

$mpdf->SetTitle('Invoice INV-2026-041');
$mpdf->SetAuthor('Northwind Studio');
$mpdf->SetSubject('Invoice for website refresh');
$mpdf->SetKeywords('invoice, Northwind, 2026');
$mpdf->SetCreator('Northwind billing system');

Set these before Output(). If you don’t call SetTitle(), mPDF uses the HTML <title> of the document, if there is one.

File name versus title

The file name comes from the first argument of Output(), and the title from SetTitle(). Many viewers show the file name in their tab or title bar, so give both a meaningful value. INV-2026-041.pdf is far more useful in a downloads folder than doc.pdf.

Language

Set the document’s language with the lang attribute on <html> or on individual elements. It affects hyphenation, font choice (see fonts and languages) and how screen readers pronounce the text.

Things to leave out

Metadata travels with the file. Don’t put internal IDs, staff names or customer details in keywords or the subject unless the recipient should see them. Anyone can read them in their viewer’s document properties.

PDF/A for archiving

If documents must be kept for years, for example invoices, contracts or records with legal retention rules, PDF/A is the archival flavour of PDF. It embeds all fonts and forbids features that might not render in the future.

$mpdf = new \Mpdf\Mpdf(['PDFA' => true, 'PDFAauto' => true]);

PDFAauto lets mPDF quietly fix things that would break compliance, such as transparency, instead of throwing an error. Validate important files with a PDF/A checker before relying on them.