An imported PDF comes back as the same objects you would have built yourself — pages, fonts, images, text. Which means modifying a document is the same work as making one, using the same API you already read on the last page.
Import a whole file, or name the pages you want and leave the rest on disk. Then stamp it, annotate it, add pages, reorder them, and write it back out.
Working from a stream rather than a path — an upload, an S3 object, a queue payload? Pdf::importRawData() takes the bytes.
Importing in the docs →use Pop\Pdf\Pdf; use Pop\Pdf\Document; // the whole file $doc = Pdf::importFromFile('contract.pdf'); // or only the pages you need $doc = Pdf::importFromFile( 'contract.pdf', [2, 4, 6] ); // register the font you stamp with $doc->addFont(Document\Font::ARIAL_BOLD); $doc->getPage(1)->addText( new Document\Page\Text('DRAFT', 48), Document\Font::ARIAL_BOLD, 180, 400 ); Pdf::writeToFile($doc, 'contract-draft.pdf');
Combine files in order, into one document object you can keep working on — add a cover page, number the result, stamp it — before you write it.
Same story for streams: Pdf::mergeRawData().
Merging in the docs →use Pop\Pdf\Pdf; $doc = Pdf::merge([ 'cover.pdf', 'body.pdf', 'appendix.pdf', ]); Pdf::writeToFile($doc, 'report.pdf');
Hand it an array of images and each one becomes a page. Useful for turning a batch of scans, screenshots or camera photos into a single document.
This is the exact inverse of extracting pages as images — the same library does the round trip.
Images to PDF in the docs →use Pop\Pdf\Pdf; $images = [ 'scans/page-01.jpg', 'scans/page-02.jpg', ]; // one page per image $doc = Pdf::importFromImages($images); Pdf::writeToFile($doc, 'scanned-batch.pdf');