From b144f0f2531c1a16e1c8c660451a658a486ae07e Mon Sep 17 00:00:00 2001 From: Johannes Date: Fri, 10 Apr 2026 10:50:55 +0200 Subject: [PATCH 1/2] Barcode am Ausweis um Steuerzeichen erweiterbar (closes Issue #369) --- .env_example | 8 ++++++-- pages/api/report/userlabels/index.tsx | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.env_example b/.env_example index b680d60..9927eb7 100644 --- a/.env_example +++ b/.env_example @@ -42,7 +42,6 @@ BARCODE_MINCODELENGTH=3 # 💾 Show backup button in the top navigation bar (1 = show, 0 = hide) ADMIN_BUTTON_SWITCH=1 - ############################################# # 🏫 BUSINESS CONFIGURATION ############################################# @@ -152,4 +151,9 @@ USERLABEL_LINE_3=["User.schoolGrade","90%","3%","35vw","2pt","black",12] # 🔲 Barcode for user labels # Format: [top, left, width, height, version] -USERLABEL_BARCODE=["80%","63%","3cm","1.6cm","code128"] \ No newline at end of file +USERLABEL_BARCODE=["80%","63%","3cm","1.6cm","code128"] + +# Prefix und Suffix für den Barcode. +# Beispiele: Escape: \x1B | Enter: \x0D | Tabulator: \x09 | Backspace: \x08 | Line Feed: \x0A | Home (Pos 1): \x01 +USERLABEL_BARCODE_PREFIX="" # Optionales Steuerzeichen vor Eingabe der Ausweisnummer (z.B. ESC) +USERLABEL_BARCODE_SUFFIX="" # Suffix für den Barcode (z.B. um mit einem Zeilenumbruch zu enden) diff --git a/pages/api/report/userlabels/index.tsx b/pages/api/report/userlabels/index.tsx index cfdb0e7..8f6a78b 100644 --- a/pages/api/report/userlabels/index.tsx +++ b/pages/api/report/userlabels/index.tsx @@ -94,6 +94,18 @@ const barcodeMinLength: number = ? parseInt(process.env.BARCODE_MINCODELENGTH) : DEFAULT_BARCODE_MINCODELENGTH; +// Postfix & Prefix for Barcode +// Hilfs-Funktion zum "Auflösen" von Hex-Strings aus Barcode Prefix/Suffix +const parseEnv = (str: string) => + str.replace(/\\x([0-9A-Fa-f]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))) + .replace(/\\r/g, "\r") + .replace(/\\n/g, "\n") + .replace(/\\t/g, "\t"); + +const barcodePrefix = parseEnv(process.env.USERLABEL_BARCODE_PREFIX || ""); +const barcodeSuffix = parseEnv(process.env.USERLABEL_BARCODE_SUFFIX || ""); + + // ============================================================================= // Styles // ============================================================================= From bae1f7e5c47d02fab70d0d6b0e0b8ea73190d32f Mon Sep 17 00:00:00 2001 From: Johannes <97600651+Geekados@users.noreply.github.com> Date: Fri, 17 Apr 2026 21:55:46 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Code-Erg=C3=A4nzung=20f=C3=BCr=20die=20Barc?= =?UTF-8?q?ode-Erstellung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fehlender Code, Steuerzeichen wurden nicht mit der Barcode-Nummer kombiniert. --- pages/api/report/userlabels/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pages/api/report/userlabels/index.tsx b/pages/api/report/userlabels/index.tsx index 8f6a78b..26a7256 100644 --- a/pages/api/report/userlabels/index.tsx +++ b/pages/api/report/userlabels/index.tsx @@ -233,13 +233,15 @@ const generateBarcode = async (id: string) => { try { const png = await bwipjs.toBuffer({ - bcid: BARCODE_SETTINGS[4], // Barcode type (e.g., 'code128') - text: barId, + bcid: BARCODE_SETTINGS[4], + text: barcodePrefix + barId + barcodeSuffix, + alttext: barId, // Zeigt unten nur die Nummer an scale: 3, + parse: true, height: 10, includetext: true, textxalign: "center", - }); + }); return (