From 9b261bf20023561a7c9691dff33c9a6d2b5c0cac Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Wed, 1 Feb 2023 17:40:09 +0100 Subject: [PATCH] fix codeconfig.height --- src/views/Profile.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/views/Profile.vue b/src/views/Profile.vue index 5626f4f..27f0161 100644 --- a/src/views/Profile.vue +++ b/src/views/Profile.vue @@ -597,18 +597,18 @@ import axios from "redaxios"; import bwipjs from "bwip-js"; function textToBase64Barcode(text) { - var canvas = document.createElement("canvas"); - // bwipjs.toCanvas(canvas, text, {format: config.code_format || "code128", displayValue:false}); - bwipjs.toCanvas(canvas, { + const canvas = document.createElement("canvas"); + let codeconfig = { bcid: config.code_format || "code128", text: `${text}` || "?", - scale: 3, // 3x scaling factor - height: 10, // Bar height, in millimeters - includetext: false, // Show human-readable text - textxalign: "center", // Always good to set this - }); + scale: 3, + includetext: false, + }; + if (codeconfig.bcid === "code128" || codeconfig.bcid === "ean13") { + codeconfig.height = 10; // bar height in mm + } + bwipjs.toCanvas(canvas, codeconfig); const base64 = canvas.toDataURL("image/png"); - console.log(base64); return base64; }