feat: migrate PDF417 barcode generation to zxing-wasm/writer

Replace custom PDF417 generation (generateBarcode/renderBarcode) with zxing-wasm's writeBarcode for improved reliability and smaller codebase. Updated all 4 components (BillEditForm, PrintPreview, ViewBillCard, ViewLocationCard) to use new Pdf417BarcodeWasm component with ecLevel 5 for error correction.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Knee Cola
2025-12-20 08:46:38 +01:00
parent 9679246f62
commit b8afb2ef0d
7 changed files with 86 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
'use client';
import { PrintBarcodeData } from '../lib/actions/printActions';
import { Pdf417Barcode } from './Pdf417Barcode';
import { Pdf417BarcodeWasm } from './Pdf417BarcodeWasm';
export interface PrintPreviewProps {
data: PrintBarcodeData[];
@@ -132,21 +132,8 @@ export const PrintPreview: React.FC<PrintPreviewProps> = ({ data, year, month, t
<td className="border-2 border-gray-800 px-3 py-1.5 text-center">
<div className="flex justify-center items-center">
{
item.hub3aText ?
<Pdf417Barcode hub3aText={item.hub3aText} className="max-h-28 w-auto max-w-[270px] print:m-[5em_auto] print:h-[auto] print:max-h-[85px] print:w-[69.6mm] print:max-w-[69.6mm]" />
: (
// LEGACY SUPPORT ... untill all bills have been migrated
item.barcodeImage ?
// eslint-disable-next-line @next/next/no-img-element
<img
src={item.barcodeImage.startsWith('data:') ? item.barcodeImage : `data:image/png;base64,${item.barcodeImage}`}
alt={`Barcode for ${item.billName}`}
className="max-h-28 w-auto max-w-[270px] print:m-[5em_auto] print:h-[auto] print:max-h-[85px] print:w-[69.6mm] print:max-w-[69.6mm]"
/> : null
)
item.hub3aText ? <Pdf417BarcodeWasm hub3aText={item.hub3aText} className="print:m-[5em_auto]" /> : null
}
</div>
</td>
</tr>