Pop PDF
Build

Metadata

Every document carries an info object — title, author and the rest of what a PDF viewer shows under "document properties".

Setting Document Metadata#

A new document starts with title, author, subject, creator and producer all set to the string 'Pop PDF' — a fresh Metadata object is never empty. Set the fields that identify your document before writing it:

PHP
use Pop\Pdf\Document;
use Pop\Pdf\Document\Page;

$document = new Document(new Page(Page::LETTER));
$document->getMetadata()->getTitle();  // 'Pop PDF'
$document->getMetadata()->getAuthor(); // 'Pop PDF'

Metadata has seven settable fields in total, each with its own set*():

PHP
use Pop\Pdf\Document\Metadata;

$metadata = new Metadata();
$metadata->setTitle('Quarterly Report')
    ->setAuthor('Jane Smith')
    ->setSubject('Q3 Financials')
    ->setCreator('Pop PDF Docs')
    ->setProducer('Pop PDF')
    ->setCreationDate('D:20260829120000')
    ->setModDate('D:20260830090000');

Pass the object to the document's constructor as its second argument:

PHP
use Pop\Pdf\Document;
use Pop\Pdf\Document\Page;
use Pop\Pdf\Pdf;

$document = new Document(new Page(Page::LETTER), metadata: $metadata);
Pdf::writeToFile($document, filename: __DIR__ . '/quarterly-report.pdf');

creationDate and modDate default to null on a fresh Metadata object — the two fields that start empty. Neither stays null in the compiled file: a document that never calls setCreationDate() or setModDate() gets both filled in at compile time with the current date and time, formatted as Sun, Aug 30, 2026 11:09 AM.

Set either explicitly and Metadata writes it byte for byte with no parsing or reformatting — a PDF-format date like D:20260829120000 comes out exactly as given.

Reading Metadata Back#

Pdf::importFromFile() returns a document whose getMetadata() reports what a source file's info object actually holds. Writing a document with all seven fields set and reading it back confirms every one survives the round trip byte for byte:

PHP
use Pop\Pdf\Pdf;

$imported = Pdf::importFromFile(__DIR__ . '/quarterly-report.pdf');
$imported->getMetadata()->getTitle();        // 'Quarterly Report'
$imported->getMetadata()->getAuthor();       // 'Jane Smith'
$imported->getMetadata()->getSubject();      // 'Q3 Financials'
$imported->getMetadata()->getCreator();      // 'Pop PDF Docs'
$imported->getMetadata()->getProducer();     // 'Pop PDF'
$imported->getMetadata()->getCreationDate(); // 'D:20260829120000'
$imported->getMetadata()->getModDate();      // 'D:20260830090000'

A document that never touches Metadata round-trips its defaults the same way — the five string fields come back as 'Pop PDF', and the two dates come back as the compile-time timestamp rather than null, since the file on disk already has both baked in:

PHP
use Pop\Pdf\Document;
use Pop\Pdf\Document\Page;
use Pop\Pdf\Pdf;

$document = new Document(new Page(Page::LETTER));
Pdf::writeToFile($document, filename: __DIR__ . '/untitled.pdf');

$imported = Pdf::importFromFile(__DIR__ . '/untitled.pdf');
$imported->getMetadata()->getTitle();        // 'Pop PDF'
$imported->getMetadata()->getAuthor();       // 'Pop PDF'
$imported->getMetadata()->getSubject();      // 'Pop PDF'
$imported->getMetadata()->getCreator();      // 'Pop PDF'
$imported->getMetadata()->getProducer();     // 'Pop PDF'
$imported->getMetadata()->getCreationDate(); // the moment writeToFile() ran, e.g. 'Sun, Aug 30, 2026 03:24 PM'
$imported->getMetadata()->getModDate();      // the same timestamp

That's what ships if setTitle(), setAuthor(), setSubject(), setCreator() and setProducer() are never called — every field visible in a PDF reader's document-properties panel reads Pop PDF rather than anything specific to the file, and the two date fields read back whatever moment the document actually compiled at.

See Also#

  • Creating Documents — the constructor argument that takes a Metadata object, plus the document's compression and version settings
  • Saving & Output — writing the compiled document to a file or a browser
  • Importing — reading an existing PDF's pages and metadata back into a document