# react-pdf-image-qr-scanner

> This is a component to scan user uploaded PDF&#x27;s and Images for QR-Codes

Latest version **1.1.1** (published 2022-01-16) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-pdf-image-qr-scanner
pnpm add react-pdf-image-qr-scanner
yarn add react-pdf-image-qr-scanner
bun add react-pdf-image-qr-scanner
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2022-01-16 |
| First published | 2021-12-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 3 |
| Unpacked size | 91.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Fallstop |
| Maintainers | fallstop |

## Links

- npm: https://www.npmjs.com/package/react-pdf-image-qr-scanner
- Repository: https://github.com/Fallstop/react-pdf-image-qr-scanner
- npm.io page: https://npm.io/package/react-pdf-image-qr-scanner

## Dependencies (3)

- [jsqr](https://npm.io/package/jsqr.md) ^1.4.0
- [pdfjs-dist](https://npm.io/package/pdfjs-dist.md) ^2.10.377
- [worker-loader](https://npm.io/package/worker-loader.md) ^3.0.8

## Recent versions

- 1.1.1 (latest) — 2022-01-16
- 1.1.0 — 2022-01-12
- 1.0.0 — 2021-12-15

## README

# react-pdf-image-qr-scanner

> This is a component to scan user uploaded PDF&#x27;s and Images for QR-Codes

[![NPM](https://img.shields.io/npm/v/react-pdf-image-qr-scanner.svg?style=flat-square)](https://www.npmjs.com/package/react-pdf-image-qr-scanner)

<h2 align="center">
	Demo
</h2>

There is a demo available [here](https://react-pdf-qr-scanner.pages.dev/). The source of the demo is in the `/example` folder.

<h2 align="center">
	Install
</h2>

```bash
yarn add react-pdf-image-qr-scanner
npm install --save react-pdf-image-qr-scanner
```
<h2 align="center">
	Usage
</h2>

```jsx
import React from 'react';

import ScanCanvasQR from 'react-pdf-image-qr-scanner';

function App() {
	const canvasScannerRef = useRef();
	const [resultText, setResultText] = useState("");

	async function scanFile(selectedFile) {
		setResultText("");
		try {
			const qrCode = await canvasScannerRef.current.scanFile(selectedFile);
			// It returns null if no QR code is found
			setResultText(qrCode || "No QR code found");
		} catch (e) {
			// Example Error Handling
			if (e?.name === "InvalidPDFException") {
				setResultText("Invalid PDF");
			} else if (e instanceof Event) {
				setResultText("Invalid Image");
			} else {
				console.log(e);
				setResultText("Unknown error");
			}
		}
	}

	return (
		<div>
			<ScanCanvasQR ref={canvasScannerRef} />
			<input type="file" onChange={(e) => { scanFile(e.target.files[0]); }} />
		</div>
	);
}
```

<h2 align="center">
	Supported By
</h2>
<p align="center">
	<a href="https://www.provida.nz/">
		<img width="250" src="./ProvidaKeaLogo.png"></img>
	</a>
</p>

---
_Source: https://npm.io/package/react-pdf-image-qr-scanner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
