@openhealthnz-credentials/pdf-image-qr-scanner

1.0.2 • Public • Published

pdf-image-qr-scanner

License Build Status NPM Package semantic-release

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 # or
yarn add @openhealthnz-credentials/pdf-image-qr-scanner

Use

import { scanFile } from "@openhealthnz-credentials/pdf-image-qr-scanner";
...
try {
    // selectedFile: File (https://developer.mozilla.org/en-US/docs/Web/API/File)
    const qrCode = await scanFile(selectedFile);
    // It returns null if no QR code is found
    console.log(qrCode || "No QR code found");
} catch (e) {
    // Example Error Handling
    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.

Package Sidebar

Install

npm i @openhealthnz-credentials/pdf-image-qr-scanner

Weekly Downloads

47

Version

1.0.2

License

MIT

Unpacked Size

50.1 kB

Total Files

22

Last publish

Collaborators

  • squareshaped
  • fallstop
  • sean-stanley
  • saille2