style: render PDF in cyberpunk A4 layout
CI and Deploy / test-build-deploy (push) Successful in 4s

This commit is contained in:
Hermes Agent
2026-08-03 14:33:20 +00:00
parent 405170a90c
commit 9f8e130d41
3 changed files with 75 additions and 20 deletions
+27 -1
View File
@@ -32,7 +32,22 @@ assert.equal(
const bytes = buildPdfBytes([
'PIZZATEIG — Napoletana',
'4 Teiglinge à 250 g · 1.000 g Teig',
'Wasser 620 g · Salz 28 g · 20 °C',
'Mehl: Caputo Pizzeria · Hydration 62 %',
'',
'ZUTATEN',
' Mehl 605 g',
' Wasser 375 g',
' Frischhefe 2,3 g',
' Salz 17 g',
'',
'ZEITPLAN',
' 19:00 Mo — Teig kneten und ruhen lassen (30 Min.)',
' 19:30 Mo — Ballen formen und bei Raumtemperatur reifen lassen',
' 23:00 Mo — Ballen in den Kühlschrank stellen',
' 15:00 Di — Ballen aus dem Kühlschrank nehmen',
' 19:00 Di — Pizza backen',
'',
'https://teig.deploybar.de/#style=napo&balls=4&ball=250&plan=d24',
]);
assert.ok(bytes instanceof Uint8Array);
const ascii = Buffer.from(bytes).toString('latin1');
@@ -40,8 +55,19 @@ assert.ok(ascii.startsWith('%PDF-1.4'));
assert.match(ascii, /\/Type \/Catalog/);
assert.match(ascii, /\/Type \/Page\b/);
assert.match(ascii, /\/Encoding \/WinAnsiEncoding/);
assert.match(ascii, /0\.027 0\.031 0\.043 rg/); // dunkler Cyberpunk-Hintergrund
assert.match(ascii, /0 0\.941 1 rg/); // Cyan-Akzent
assert.match(ascii, /1 0\.176 0\.471 rg/); // Magenta-Akzent
assert.match(ascii, /xref\n0 \d+/);
assert.match(ascii, /%%EOF\n$/);
assert.match(ascii, /\/Count 1\b/);
const longPdf = Buffer.from(buildPdfBytes([
'PIZZATEIG — Belastungstest',
...Array.from({ length: 120 }, (_, i) => `ZEILE ${i + 1} — Rezeptinformation`),
])).toString('latin1');
assert.match(longPdf, /\/Count 1\b/, 'PDF muss auf genau eine Seite begrenzt bleiben');
assert.equal((longPdf.match(/\/Type \/Page\b/g) || []).length, 1, 'PDF enthält mehr als eine A4-Seite');
fs.writeFileSync('/tmp/teig-terminal-download-test.pdf', Buffer.from(bytes));
console.log('pdf download tests: OK');