withDeterministic(new DeterministicSettings( new DateTimeImmutable('2026-07-24T00:00:00Z'), \str_repeat('a', 32), )); $doc = Document::createStandalone($config); $doc->setTitle('Payment Barcode Sample Sheet'); $doc->setPrintFooter(false); $doc->addPage(); $doc->setFont('helvetica', 'B', 18); $doc->setXY(24, 20); $doc->cell(0, 12, 'Medical and Payment Barcode Sample Sheet', newLine: true); $caption = static function ( Document $document, float $x, string $cellId, array $details, ): void { $publicCellId = \preg_replace('/^w[0-9]+-/', '', $cellId) ?? $cellId; $document->setFont('helvetica', '', 5.5); foreach (["CELL {$publicCellId}:", ...$details] as $line => $text) { $document->setXY($x, 50 + ($line * 8)); $document->cell(130, 8, $text); } }; $capabilities = CapabilityRegistry::getInstance(); $hibcAvailable = $capabilities->has('barcode.hibc') && $capabilities->get('barcode.hibc')->isAvailable() && \class_exists(HibcLicEncoder::class) && \class_exists(HibcUdiProfile::class); $paymentAvailable = $capabilities->has('barcode.payment') && $capabilities->get('barcode.payment')->isAvailable() && \class_exists(SwissQrBill::class) && \class_exists(EpcQrCode::class); if ($hibcAvailable) { $licPayload = (new HibcLicEncoder())->encodePrimary('A123', 'BJC5D6E7', 1); $caption($doc, 24, 'w1-hibc-lic', ['HIBC LIC / version=primary', 'ECC=mod-43', "payload={$licPayload}"]); $doc->write1DBarcode($licPayload, BarcodeType::C128, x: 35, y: 105, w: 115, h: 60); $udi = (new HibcUdiProfile())->encodePrimaryAndSecondary( 'A999', '1234', 5, '$$52001510X3', HibcCarrier::DataMatrix, ); $udiPayload = $udi['payload']; $caption($doc, 164, 'w1-hibc-udi', ['HIBC UDI / version=LIC primary+secondary', 'ECC=ECC200', "payload={$udiPayload}"]); $doc->write2DBarcode($udiPayload, Barcode2DType::DataMatrix, x: 180, y: 105, w: 105, h: 105); } if ($paymentAvailable) { $swissInput = new SwissQrBillData( account: 'CH5800791123000889012', creditorName: 'Max Muster & Söhne', creditorPostalCode: '9490', creditorTown: 'Vaduz', creditorCountry: 'LI', creditorStreet: 'Musterstrasse', creditorBuildingNumber: '123', amount: '199.95', currency: 'CHF', debtorAddressType: 'S', debtorName: 'Sarah Beispiel', debtorStreet: 'Musterstrasse', debtorBuildingNumber: '1', debtorPostalCode: '8000', debtorTown: 'Seldwyla', debtorCountry: 'CH', referenceType: 'SCOR', reference: 'RF18539007547034', ); $caption($doc, 304, 'w1-swiss-qr-bill', [ 'Swiss QR-bill / version=SPC 0200', 'ECC=M', 'payload=CH5800791123000889012', 'CHF199.95|RF18539007547034', ]); (new SwissQrBill())->write($doc, $swissInput, 320, 730); $epcPayment = new EpcQrPayment( beneficiaryName: 'Franz Mustermänn', iban: 'DE71110220330123456789', version: '001', characterSet: 1, bic: 'BHBLDEHHXXX', amount: 'EUR12.3', purpose: 'GDDS', structuredRemittance: 'RF18539007547034', ); $epcPayload = (new EpcQrCode())->buildPayload($epcPayment); $caption($doc, 444, 'w1-epc-qr', [ 'EPC QR / version=001', 'ECC=M', 'payload=BCD|001|SCT', 'DE71110220330123456789|EUR12.3', ]); $doc->write2DBarcodeWithOptions( $epcPayload, Barcode2DType::QRCode, symbolOptions: new QrCodeOptions(ecLevel: 'M', version: 6), x: 460, y: 105, w: 105, h: 105, ); } $output = \getenv('NEXTPDF_SAMPLE_OUTPUT') ?: __DIR__ . '/../output/46-barcode-payment.pdf'; $doc->save($output); if (!$hibcAvailable) { echo "SKIP: HIBC cells require nextpdf/pro\n"; } if (!$paymentAvailable) { echo "SKIP: payment cells require nextpdf/pro\n"; } echo "Created: {$output}\n";