@@ -11,14 +11,19 @@ asyncHelpers.set('--bc', generateBarcode);
|
||||
export const helpers = asyncHelpers.get({ wrap: true });
|
||||
|
||||
export async function generateBase64Barcode(type: string, content: string): Promise<String> {
|
||||
let barcode: Buffer = await bwipjs.toBuffer({
|
||||
let options = {
|
||||
bcid: type,
|
||||
text: content,
|
||||
scale: 3,
|
||||
scale: 4,
|
||||
height: 10,
|
||||
width: 10,
|
||||
includetext: true,
|
||||
textxalign: 'center',
|
||||
});
|
||||
}
|
||||
if (type != "qrcode") {
|
||||
delete options.width;
|
||||
}
|
||||
const barcode: Buffer = await bwipjs.toBuffer(options);
|
||||
return `data:image/png;base64,${barcode.toString('base64')}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user