Now with working code scaleing

ref #13
This commit is contained in:
2021-02-09 17:02:02 +01:00
parent edc846ab05
commit 4b79b29ee6
2 changed files with 19 additions and 13 deletions

View File

@@ -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')}`;
}