Files
buildfor_life_repair/src/lib/server/barcode.ts
T
grabowski a0e32e679e
Deploy to LXC / deploy (push) Successful in 19s
Label: large ID below barcode (9pt, same as title), left-align text
- Barcode rendered without embedded text (includetext: false)
- ID rendered as separate HTML text at 9pt bold with letter-spacing
- All label text left-aligned instead of centred
- Barcode height reduced to 5mm to fit

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

17 lines
433 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: false,
textxalign: 'center'
});
// Return as base64 data URL for embedding in HTML
return `data:image/png;base64,${buf.toString('base64')}`;
}