Files
buildfor_life_repair/src/lib/server/barcode.ts
T
grabowski 2f1675af1d
Deploy to LXC / deploy (push) Successful in 19s
Fix 2-page label: reset @page margin to 0, shrink barcode to fit
The custom @page margins conflicted with browser minimum margins,
causing overflow. Now @page margin is 0, barcode height 8mm→6mm,
scale 3→2, text size 12→10 so content fits within 29mm even with
browser minimum margins selected.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 09:52:01 +07:00

18 lines
448 B
TypeScript

// @ts-expect-error bwip-js types not resolved by bundler moduleResolution
import bwipjs from 'bwip-js';
export async function generateBarcodeSvg(text: string): Promise<string> {
const buf = await bwipjs.toBuffer({
bcid: 'code128',
text,
scale: 2,
height: 8,
includetext: true,
textsize: 10,
textxalign: 'center'
});
// Return as base64 data URL for embedding in HTML
return `data:image/png;base64,${buf.toString('base64')}`;
}