withDeterministic(new DeterministicSettings( new DateTimeImmutable('2026-07-24T00:00:00Z'), \str_repeat('9', 32), )); $doc = Document::createStandalone($config); $doc->setTitle('Postal Barcode Sample Sheet'); $doc->setPrintFooter(false); $doc->addPage(new PageSize(1200, 700, 'PostalSheet'), Orientation::Landscape); $doc->setFont('helvetica', 'B', 18); $doc->setXY(24, 20); $doc->cell(0, 12, 'Postal Barcode Sample Sheet', newLine: true); $doc->setFont('helvetica', '', 7); $caption = static function (Document $document, float $x, float $y, string $text): void { $parts = \explode(' / ', $text, 4); if (\count($parts) !== 4) { throw new LogicException('Postal caption must contain four slash-delimited fields.'); } $document->setFont('helvetica', '', 7); foreach ([$parts[0], $parts[1] . ' / ' . $parts[2], $parts[3]] as $line => $captionLine) { $document->setXY($x, $y + ($line * 10)); $document->cell(275, 10, $captionLine); } }; $capabilities = CapabilityRegistry::getInstance(); $postalAvailable = $capabilities->has('barcode.postal') && $capabilities->get('barcode.postal')->isAvailable(); if ($postalAvailable) { $caption($doc, 24, 65, 'CELL rm4scc: RM4SCC / version=4-state / ECC=check-character / payload=SN34RD1A'); $doc->write1DBarcode('SN34RD1A', BarcodeType::RM4SCC, x: 35, y: 100, w: 245, h: 60); $caption($doc, 314, 65, 'CELL auspost: Australia Post / version=FCC-11 / ECC=Reed-Solomon / payload=1139549554'); $doc->write1DBarcode('1139549554', BarcodeType::AUSPOST, x: 325, y: 100, w: 245, h: 60); $caption($doc, 604, 65, 'CELL japanpost: Japan Post / version=customer / ECC=check-character / payload=10000131-3-2-503'); $doc->write1DBarcode('10000131-3-2-503', BarcodeType::JAPANPOST, x: 615, y: 100, w: 245, h: 60); $caption($doc, 894, 65, 'CELL mailmark: Mailmark / version=C / ECC=Reed-Solomon / payload=1100000000000XY11[5 spaces]'); $doc->write1DBarcode('1100000000000XY11 ', BarcodeType::MAILMARK, x: 905, y: 100, w: 245, h: 60); $caption($doc, 24, 325, 'CELL kix-refusal: KIX / version=4-state / ECC=n/a / payload=2500GG30250'); try { $doc->write1DBarcode('2500GG30250', BarcodeType::KIX, x: 35, y: 365, w: 245, h: 60); throw new LogicException('KIX unexpectedly rendered instead of failing closed.'); } catch (KixCharacterTableUnavailableException) { $doc->setFont('helvetica', 'B', 8); $doc->setXY(35, 385); $doc->cell(245, 12, 'TYPED REFUSAL: KixCharacterTableUnavailableException'); $doc->setFont('helvetica', '', 7); } $caption($doc, 314, 325, 'CELL leitcode: Leitcode / version=I25 / ECC=mod-10 / payload=2134807501640 -> 21348075016401'); $doc->write1DBarcode('2134807501640', BarcodeType::LEITCODE, x: 325, y: 365, w: 245, h: 60); $caption($doc, 604, 325, 'CELL identcode: Identcode / version=I25 / ECC=mod-10 / payload=56310243031 -> 563102430313'); $doc->write1DBarcode('56310243031', BarcodeType::IDENTCODE, x: 615, y: 365, w: 245, h: 60); } $output = \getenv('NEXTPDF_SAMPLE_OUTPUT') ?: __DIR__ . '/../output/45-barcode-postal.pdf'; $doc->save($output); if (!$postalAvailable) { echo "SKIP: postal cells require nextpdf/pro\n"; } echo "SKIP: w1-kix-refusal is a typed fail-closed result, not a rendered symbol\n"; echo "Created: {$output}\n";