pdf-image-qr-scanner
Library to scan user-uploaded PDF's or images locally and reliably for QR codes using jsQR.
Install
npm install @openhealthnz-credentials/pdf-image-qr-scanner
yarn add @openhealthnz-credentials/pdf-image-qr-scanner
Use
import { scanFile } from "@openhealthnz-credentials/pdf-image-qr-scanner";
...
try {
const qrCode = await scanFile(selectedFile);
console.log(qrCode || "No QR code found");
} catch (e) {
if (e?.name === "InvalidPDFException") {
console.log("Invalid PDF");
} else if (e instanceof Event) {
console.log("Invalid Image");
} else {
console.log("Unknown error:", e);
}
}
Additional examples available in the the examples folder.
TODO:
- Implement AVA tests with browser polyfills.
Supported By