Skip to content

A comprehensive Python project for generating and reading QR codes, with support for embedding QR codes in PDF documents

Notifications You must be signed in to change notification settings

gRiverOS/qr-code-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QR Code Generator & Reader

A comprehensive Python project for generating and reading QR codes, with support for embedding QR codes in PDF documents.

🚀 Features

  • QR Code Generation: Create QR codes with custom data
  • QR Code Reading: Programmatically read QR codes from images
  • PDF Integration: Embed QR codes in PDF documents
  • Multiple Reading Methods: Support for various QR code reading libraries
  • Easy Setup: Virtual environment with all dependencies

📦 Installation

Prerequisites

  • Python 3.8+
  • pip

Setup

  1. Clone the repository:
git clone <repository-url>
cd qr-code
  1. Create and activate virtual environment:
python3 -m venv qr_env
source qr_env/bin/activate  # On Windows: qr_env\Scripts\activate
  1. Install dependencies:
pip install qrcode pillow zxing-cpp reportlab

🎯 Usage

Quick Start

Run the project with the included script:

./run_qr.sh

Manual Usage

Activate the virtual environment and run scripts:

source qr_env/bin/activate
python generate_qr.py      # Generate QR code
python read_qr_zxing.py    # Read QR codes
python pdf_with_qr.py      # Create PDF with QR code
python qr_info.py          # Show QR code information

📁 Project Structure

qr-code/
├── generate_qr.py          # Generate QR codes
├── read_qr_zxing.py       # Read QR codes programmatically
├── pdf_with_qr.py         # Create PDFs with embedded QR codes
├── qr_info.py             # QR code information and reading methods
├── run_qr.sh              # Easy runner script
├── qr_env/                # Virtual environment
├── .gitignore             # Git ignore file
└── README.md              # This file

🔧 Scripts Description

generate_qr.py

Generates a QR code with delivery guide information and saves it as PNG.

Example Output:

GD:123456 | RUT:96543210-5 | Fecha:2025-10-25 | Total:$1.250.000 | Ítems:4

read_qr_zxing.py

Reads QR codes from image files using the zxing-cpp library.

Features:

  • Read QR codes from PNG files
  • Decode QR codes from memory
  • Display decoded data and format information

pdf_with_qr.py

Creates PDF documents with embedded QR codes.

Features:

  • Generate QR codes in memory
  • Embed QR codes in PDF documents
  • Customizable positioning and sizing

qr_info.py

Provides comprehensive information about QR code reading methods.

Information includes:

  • Phone camera methods
  • Online QR readers
  • Desktop applications
  • Programmatic reading options

📱 How to Read QR Codes

1. Phone Camera (Easiest)

  • iPhone: Open Camera app, point at QR code
  • Android: Open Camera app or Google Lens
  • Most smartphones detect QR codes automatically

2. Online Readers

3. Desktop Applications

  • macOS: Press spacebar on QR code image (Quick Look)
  • Windows: Use Camera app or QR scanner apps
  • Linux: Install qrencode or similar tools

4. Mobile Apps

  • QR Code Reader (iOS/Android)
  • QR Scanner (iOS/Android)
  • Google Lens (Android)

🛠️ Dependencies

  • qrcode: QR code generation
  • pillow: Image processing
  • zxing-cpp: QR code reading
  • reportlab: PDF generation

📋 Example Usage

Generate QR Code

import qrcode

data = "GD:123456 | RUT:96543210-5 | Fecha:2025-10-25 | Total:$1.250.000 | Ítems:4"
img = qrcode.make(data)
img.save("delivery_qr.png")

Read QR Code

import zxingcpp
from PIL import Image

image = Image.open("delivery_qr.png")
results = zxingcpp.read_barcodes(image)
for result in results:
    print(f"Data: {result.text}")

Create PDF with QR Code

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A4
from reportlab.lib.utils import ImageReader
import qrcode
from io import BytesIO

# Generate QR code
data = "GD:123456 | Fecha:2025-10-25 | Total:$1.250.000"
qr = qrcode.make(data)
buffer = BytesIO()
qr.save(buffer, format="PNG")
buffer.seek(0)

# Create PDF
c = canvas.Canvas("delivery_guide.pdf", pagesize=A4)
qr_image = ImageReader(buffer)
c.drawImage(qr_image, 450, 720, width=100, height=100)
c.save()

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

📞 Support

If you have any questions or need help, please open an issue in the repository.


Happy QR Coding! 🎉

About

A comprehensive Python project for generating and reading QR codes, with support for embedding QR codes in PDF documents

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published