a0e32e679e
Deploy to LXC / deploy (push) Successful in 19s
- 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>
17 lines
433 B
TypeScript
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')}`;
|
|
}
|