An open API service indexing awesome lists of open source software.

https://github.com/olekacak/qr-scanner

This Python project scans and decodes QR codes from each page of a PDF. It extracts the QR code data and opens URLs found within the QR codes in the web browser. It uses libraries like OpenCV, Pyzbar, and pdf2image to process the PDF and detect QR codes for efficient scanning and URL handling.
https://github.com/olekacak/qr-scanner

barcode-recognition opencv pdf-to-image-conversion pyzbar qr-code-scanning qrcode web-scraping

Last synced: about 1 month ago
JSON representation

This Python project scans and decodes QR codes from each page of a PDF. It extracts the QR code data and opens URLs found within the QR codes in the web browser. It uses libraries like OpenCV, Pyzbar, and pdf2image to process the PDF and detect QR codes for efficient scanning and URL handling.

Awesome Lists containing this project

README

          

# QR Code Scanner from PDF (Python)

This Python script scans and decodes QR codes embedded in a PDF file. If a QR code contains a URL, it will automatically open it in your default web browser.

## ๐Ÿ“ฆ Requirements

- Python 3.7 or higher
- [Poppler](http://blog.alivate.com.au/poppler-windows/) (required for `pdf2image` to work)
- Python packages:
- opencv-python
- pyzbar
- pdf2image
- numpy

## โš™๏ธ Installation

1. **Clone the repository or download the files.**

2. **Install the required Python packages**
Run this command in your terminal or command prompt to install dependencies from the `requirements.txt` file:
```
pip install -r requirements.txt
```

3. **Install Poppler**
- **Windows**:
Download from [this link](http://blog.alivate.com.au/poppler-windows/), extract it, and add the `bin` folder to your systemโ€™s PATH.
- **macOS**:
Use Homebrew:
```
brew install poppler
```

## ๐Ÿš€ Usage

1. Open the script and update the PDF path:
```python
pdf_path = "C:\Users\YourName\Path\To\yourfile.pdf"
```

2. Run the script:
```
python your_script_name.py
```

3. The script will:
- Convert each page of the PDF into an image
- Detect QR codes on each page
- Print the decoded data to the terminal
- Automatically open any URLs found in your browser

## โœ… Example Output

```
QR Code Data (Page 1): https://example.com
QR Code Data (Page 2): Hello World
Scanned QR code on Page 2 is not a URL.
No QR code found on Page 3.
```

## ๐Ÿ“Œ Notes

- Best results are achieved with clear and high-resolution PDFs (300 DPI recommended).
- If QR codes are too small or blurry, they may not be detected.

## ๐Ÿงพ License

MIT License

Copyright (c) 2025 Amier Roslan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.