$page->addLink(Box::fromMm(20, 250, 60, 8), 'https://example.com/');
$page->addLink(Box::fromMm(20, 240, 60, 8), 'mailto:[email protected]');
$page->addLink($box, Destination::page(3)); // whole page
$page->addLink($box, Destination::top(3, 700)); // scrolled so y = 700 is at the top
$page->addLink($box, Destination::at(3, 72, 500, zoom: 1.5));
$page->addLink($box, Destination::named('chapter-2'));
Text in a Textflow links with <a href="…"> (see textflow.md).
addLink($area, $target, tooltip: 'Opens in a browser') adds a tooltip viewers show when the
pointer rests on the link. Links draw nothing; style the content underneath. The area is in the page’s coordinate mode.
Links may point at pages that do not exist yet: annotations are written when the document closes.
$doc->addDestination('chapter-2', Destination::top(5, 700));
$outline = $doc->outline();
$two = $outline->add('Chapter 2', 5); // a page number means Destination::page()
$two->add('Section 2.1', Destination::at(5, 0, 400));
$two->add('Section 2.2', Destination::named('chapter-2'), open: false);
Destination coordinates are in the target page’s PDF user space (origin bottom-left, points).
Named destinations are written to the catalog’s name tree (/Names /Dests), where links and
bookmarks that refer to them by name are looked up.
$doc = new Document('print.pdf', new DocumentOptions(
pdfx: PdfX::X4,
rgbProfile: IccProfile::fromFile('sRGB.icc'),
));
$doc->info()->setTitle('Brochure');
$doc->setOutputIntent(IccProfile::fromFile('ISOcoated_v2_300_eci.icc'), 'FOGRA39', 'Coated FOGRA39 (ISO 12647-2:2004)');
What the option does:
GTS_PDFXVersion and Trapped in the Info dictionary and the XMP
packet (pdfxid:GTS_PDFXVersion, pdf:Trapped);xmpMM:VersionID and xmpMM:RenditionClass in the XMP packet;DefaultRGB ICCBased colour space to every resource dictionary, so RGB colours and
images are device-independent;Page boxes are checked as they are set, and a link as soon as it is added once the page has a bleed, trim or art box, so the exception comes from the call that broke the rule and the refused box or link is not kept. When moving boxes that are already set, keep each step valid: enlarge the bleed box before the trim box, and shrink the trim box before the bleed box. A link added before any box is set is checked when the page is finished, before anything of the page is written; a page that fails stays open, so it can be corrected and the document closed.
Fonts are always embedded. The structure follows ISO 15930-7; check files with Acrobat Preflight or callas pdfToolbox (veraPDF validates PDF/A and PDF/UA, not PDF/X).
Colours, gradients and images are checked against the output intent’s colour space when they are first used, so the error points at the offending call:
| Device colour | Grey intent | RGB intent | CMYK intent |
|---|---|---|---|
Gray |
yes | yes | yes |
Rgb |
with rgbProfile |
yes | with rgbProfile |
Cmyk |
no | no | yes |
A Spot colour is checked by its alternate. ICC-based images and colours are always allowed;
a palette image is checked by its base colour space. Set the output intent before drawing in
colour.
Imported pages are scanned for the device colour spaces they draw with (in their content, forms,
images, shadings and patterns) and must match the output intent itself: rgbProfile does not
apply to them, because their DefaultRGB resources are their own. Convert artwork to the
output intent’s colour space before importing it.