applyLayout($doc); $template->applyMetadata($doc); $template->registerFaces($doc, [['Barlow', 'B'], ['Inter', 'B']]); $doc->setPrintHeader(false); $doc->setPrintFooter(false); // The writer reserves the `helvetica` resource key for untagged header/footer // compatibility. Materialize that key with the vendored Inter program so the // PDF/X font preflight never sees the unembedded Base14 fallback. $doc->getFontRegistry()->register(Typography::expectedFontFiles()[0], 'helvetica'); $doc->setFont('helvetica', '', Typography::SIZE_BODY); $doc->encodeTextForFont('0', 'helvetica'); $doc->setFont(Typography::FAMILY_TEXT, '', Typography::SIZE_BODY); $doc->enablePdfX( target: ConformanceTarget::pdfX4(), binding: PdfXActivation::activateCoatedFogra39(), ); $doc->addPage(); $doc->setTrimBox(0.0, 0.0, $doc->getPageWidth(), $doc->getPageHeight()); /** * @param array{0: float, 1: float, 2: float, 3: float} $cmyk */ $text = static function ( Document $document, float $x, float $y, string $value, string $family = 'Inter', string $style = '', float $size = 9.0, array $cmyk = [0.0, 0.0, 0.0, 88.0], ): void { $document->setFont($family, $style, $size); $document->setTextColorCmyk(...$cmyk); $document->text($x, $y, $value); }; $pageWidth = $doc->getPageWidth(); // Full-width 16 mm identity band. $doc->setFillColorCmyk(100.0, 78.0, 18.0, 46.0); $doc->rect(0.0, 0.0, $pageWidth, 45.35, 'F'); $text($doc, 43.0, 29.0, 'NEXTPDF / PRINT PRODUCTION', 'Inter', 'B', 9.0, [0.0, 0.0, 0.0, 0.0]); $text($doc, 430.0, 29.0, 'PDF/X-4', 'Inter', 'B', 9.0, [0.0, 0.0, 0.0, 0.0]); // Compact CMYK vector mark kept inside the sample template logo zone. $doc->setFillColorCmyk(100.0, 5.0, 0.0, 0.0); $doc->rect(45.0, 76.0, 14.0, 14.0, 'F'); $doc->setFillColorCmyk(0.0, 92.0, 8.0, 0.0); $doc->rect(61.0, 76.0, 14.0, 14.0, 'F'); $doc->setFillColorCmyk(0.0, 12.0, 100.0, 0.0); $doc->rect(45.0, 92.0, 14.0, 14.0, 'F'); $doc->setFillColorCmyk(70.0, 0.0, 86.0, 5.0); $doc->rect(61.0, 92.0, 14.0, 14.0, 'F'); $text($doc, 91.0, 88.0, 'Print-Ready Color Sheet', 'Barlow', 'B', 22.0); $text($doc, 92.0, 105.0, 'Declared print condition / process-color reference', 'Inter', '', 8.5, [0.0, 0.0, 0.0, 55.0]); // The familiar 2 x 5 sample specification table, rendered without RGB CSS. $specCells = $spec->specTableCells(); $labels = \array_map(static fn (string $label): string => \strtoupper($label), $specCells['labels']); $values = $specCells['values']; $columnX = [43.0, 105.0, 250.0, 390.0, 480.0]; $doc->setFillColorCmyk(0.0, 0.0, 0.0, 4.0); $doc->rect(43.0, 122.0, 509.0, 45.0, 'F'); $doc->setDrawColorCmyk(0.0, 0.0, 0.0, 18.0); $doc->line(43.0, 145.0, 552.0, 145.0); foreach ($labels as $index => $label) { $text($doc, $columnX[$index], 138.0, $label, 'Inter', 'B', 6.5, [0.0, 0.0, 0.0, 55.0]); $text($doc, $columnX[$index], 159.0, $values[$index], 'Inter', '', 7.2); } $text($doc, 43.0, 193.0, 'PDF/X-4 output configuration', 'Barlow', 'B', 13.0); $intro = [ 'Configured for PDF/X-4 on PDF 1.6; the catalog declares', 'one GTS_PDFX output intent with the embedded Coated FOGRA39 CMYK printer profile.', 'The output target selects ISO 15930-7 for color-managed print and proofing workflows.', ]; foreach ($intro as $index => $line) { $text($doc, 43.0, 212.0 + ($index * 13.0), $line, 'Inter', '', 9.0); } $text($doc, 43.0, 270.0, 'WHY IT MATTERS', 'Inter', 'B', 7.0, [0.0, 0.0, 0.0, 52.0]); $why = [ 'A declared output intent gives RIPs, proofers, and soft-proofing viewers', 'one characterized printing condition. Preview and press decisions can use', 'the same reference instead of guessing a working space per viewer.', ]; foreach ($why as $index => $line) { $text($doc, 43.0, 286.0 + ($index * 12.5), $line, 'Inter', '', 8.5, [0.0, 0.0, 0.0, 62.0]); } $doc->setFillColorCmyk(0.0, 0.0, 0.0, 4.0); $doc->rect(377.0, 258.0, 175.0, 63.0, 'F'); $text($doc, 390.0, 273.0, 'DECLARED INTENT', 'Inter', 'B', 7.0, [0.0, 0.0, 0.0, 52.0]); $text($doc, 390.0, 289.0, 'Space / CMYK', 'Inter', '', 8.0); $text($doc, 390.0, 302.0, 'Profile / CoatedFOGRA39.icc', 'Inter', '', 8.0); $text($doc, 390.0, 315.0, 'ICC v2 / GTS_PDFX', 'Inter', '', 8.0); $text($doc, 43.0, 350.0, 'Print color reference bar', 'Barlow', 'B', 11.0); $text($doc, 43.0, 366.0, 'Six process-color swatches exercise the CMYK content path used by the declared print condition.', 'Inter', '', 8.0, [0.0, 0.0, 0.0, 58.0]); $swatches = [ [[100.0, 0.0, 0.0, 0.0], 'C 100'], [[0.0, 100.0, 0.0, 0.0], 'M 100'], [[0.0, 0.0, 100.0, 0.0], 'Y 100'], [[0.0, 100.0, 100.0, 0.0], 'M100 Y100'], [[100.0, 0.0, 100.0, 0.0], 'C100 Y100'], [[100.0, 100.0, 0.0, 0.0], 'C100 M100'], ]; $swatchWidth = 84.833; foreach ($swatches as $index => [$color, $label]) { $x = 43.0 + ($index * $swatchWidth); $doc->setFillColorCmyk(...$color); $doc->rect($x, 380.0, $swatchWidth, 34.0, 'F'); $text($doc, $x + 5.0, 428.0, $label, 'Inter', '', 6.5, [0.0, 0.0, 0.0, 62.0]); } $text($doc, 43.0, 460.0, 'Recommended workflow', 'Barlow', 'B', 11.0); $workflow = [ '1 Author and preview content for the declared Coated FOGRA39 printing condition.', '2 Soft-proof, or pull a calibrated hard proof, before committing to plates.', '3 Confirm /OutputIntents survives merges, flattening, redaction, or other processing.', ]; foreach ($workflow as $index => $line) { $text($doc, 43.0, 479.0 + ($index * 18.0), $line, 'Inter', '', 8.5); } $text($doc, 43.0, 551.0, 'PDF/X-4 configuration identity', 'Barlow', 'B', 11.0); $text($doc, 43.0, 567.0, 'The writer validates the emitted object graph before releasing the file.', 'Inter', '', 8.0, [0.0, 0.0, 0.0, 58.0]); $identity = [ ['Conformance target', 'PDF/X-4'], ['Base serialization', 'PDF 1.6'], ['Output condition', 'Coated FOGRA39'], ['Output intent subtype', 'GTS_PDFX'], ['Destination color space', 'CMYK'], ]; $tableTop = 580.0; $rowHeight = 24.0; $doc->setDrawColorCmyk(0.0, 0.0, 0.0, 18.0); $doc->rect(43.0, $tableTop, 509.0, $rowHeight * \count($identity), 'S'); $doc->line(278.0, $tableTop, 278.0, $tableTop + ($rowHeight * \count($identity))); foreach ($identity as $index => [$property, $value]) { $rowY = $tableTop + ($index * $rowHeight); if ($index % 2 === 1) { $doc->setFillColorCmyk(0.0, 0.0, 0.0, 4.0); $doc->rect(43.0, $rowY, 509.0, $rowHeight, 'F'); } if ($index > 0) { $doc->setDrawColorCmyk(0.0, 0.0, 0.0, 18.0); $doc->line(43.0, $rowY, 552.0, $rowY); } $text($doc, 55.0, $rowY + 16.0, $property, 'Inter', '', 8.0, [0.0, 0.0, 0.0, 58.0]); $text($doc, 291.0, $rowY + 16.0, $value, 'Inter', $index === 0 ? 'B' : '', 8.0); } $text($doc, 43.0, 724.0, 'Configured for PDF/X-4 on PDF 1.6 with a Coated FOGRA39 output intent.', 'Inter', '', 7.5, [0.0, 0.0, 0.0, 58.0]); $text($doc, 43.0, 737.0, 'Use a calibrated proof to evaluate production color.', 'Inter', '', 7.5, [0.0, 0.0, 0.0, 58.0]); // Static one-page footer: no RGB template callbacks and no page-count placeholder. $doc->setDrawColorCmyk(0.0, 0.0, 0.0, 20.0); $doc->line(43.0, 786.0, 552.0, 786.0); $text($doc, 43.0, 806.0, 'NextPDF SAMPLE', 'Inter', 'B', 7.0, [0.0, 0.0, 0.0, 58.0]); $text($doc, 254.0, 806.0, 'getnextpdf.com', 'Inter', '', 7.0, [0.0, 0.0, 0.0, 58.0]); $text($doc, 523.0, 806.0, '1 / 1', 'Inter', '', 7.0, [0.0, 0.0, 0.0, 58.0]); $output = \getenv('NEXTPDF_SAMPLE_OUTPUT') ?: __DIR__ . '/../output/print-ready.pdf'; $doc->save($output); echo "Created: {$output}\n";