From fb3393c985f3a78f3cf1fcda55fd85c3aa851aef Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sun, 23 Nov 2025 12:53:35 +0100 Subject: [PATCH 1/2] (bugfix) decoding hub3a from image did not work --- app/lib/pdf/barcodeDecoder.ts | 17 +++++++++++++++-- app/ui/BillEditForm.tsx | 4 ++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/lib/pdf/barcodeDecoder.ts b/app/lib/pdf/barcodeDecoder.ts index f74d610..2110bcc 100644 --- a/app/lib/pdf/barcodeDecoder.ts +++ b/app/lib/pdf/barcodeDecoder.ts @@ -309,8 +309,21 @@ const decodeFromCanvas = async (canvas:HTMLCanvasElement): Promise => { - return(await decodeFromCanvas( await image2canvas(imageBase64) )); +export const decodeFromImage = async (imageBase64:string): Promise => { + const canvas = await image2canvas(imageBase64); + + const hints = new Map(); + hints.set(DecodeHintType.POSSIBLE_FORMATS, [ BarcodeFormat.PDF_417 ]); + hints.set(DecodeHintType.PURE_BARCODE, false); + + const codeReader = new BrowserPDF417Reader(hints); + const result = await codeReader.decodeFromCanvas(canvas); + const hub3aText = result.getText(); + + return({ + hub3aText, + billInfo: parseHubText(hub3aText) + }); } /** Finds PDF417 code within a file and decodes it */ diff --git a/app/ui/BillEditForm.tsx b/app/ui/BillEditForm.tsx index b51a138..2c06236 100644 --- a/app/ui/BillEditForm.tsx +++ b/app/ui/BillEditForm.tsx @@ -53,10 +53,10 @@ export const BillEditForm: FC = ({ location, bill }) => { // by converting it to `hub3aText` if (!hub3aText && bill?.barcodeImage) { decodeFromImage(bill.barcodeImage).then(results => { - if (results && results.length > 0) { + if (results) { const { hub3aText: decodedHub3aText, - } = results[0]; + } = results; setHub3aText(decodedHub3aText); } From 8998bbae7d7bfbf813be7f162935d6d071f47a82 Mon Sep 17 00:00:00 2001 From: Knee Cola Date: Sun, 23 Nov 2025 12:54:25 +0100 Subject: [PATCH 2/2] 2.0.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e357094..175f677 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "evidencija-rezija", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "version": "2.0.0", + "version": "2.0.1", "dependencies": { "@emotion/react": "^11.14.0", "@emotion/styled": "^11.14.1", diff --git a/package.json b/package.json index b0a7ace..1199c9b 100644 --- a/package.json +++ b/package.json @@ -58,5 +58,5 @@ "engines": { "node": ">=18.17.0" }, - "version": "2.0.0" + "version": "2.0.1" }