Onflow AWB OCR
Python SDK for extracting receiver information from AWB and shipping label files.
The package supports PDF files with a text layer first, then falls back to OCR for scanned PDFs and image files when OCR dependencies are installed.
Requirements
- Python 3.8+
- PyMuPDF for PDF text-layer extraction
- Optional OCR stack for scanned files and images:
- Tesseract OCR
- Vietnamese Tesseract language data
- Poppler
pdftoppm
Installation
Install from PyPI:
pip install onflow-awb-ocr
Install with OCR dependencies:
pip install "onflow-awb-ocr[ocr]"
On Ubuntu, install the native OCR tools:
sudo apt install -y tesseract-ocr tesseract-ocr-vie poppler-utils
For local development:
pip install -e ".[ocr]"
Usage
from onflow_awb_ocr import OnflowAwbOcr
ocr = OnflowAwbOcr(lang="vie+eng")
result = ocr.extract("label.pdf")
print(result)
Example result:
{
"name": "Nguyen Van A",
"address": "123 Nguyen Trai\nQuan 1, TP. Ho Chi Minh",
"strategy": "shopee",
}
If no receiver can be detected, extract() returns None.
Supported Inputs
extract() accepts:
- Local file path as
str - Local file path as
pathlib.Path - HTTP/HTTPS URL
bytesbytearray- Binary file-like object
Examples:
from pathlib import Path
from onflow_awb_ocr import OnflowAwbOcr
ocr = OnflowAwbOcr()
from_path = ocr.extract(Path("label.pdf"))
from_url = ocr.extract("https://example.com/label.pdf")
with open("label.pdf", "rb") as file:
from_file = ocr.extract(file)
with open("label.png", "rb") as file:
from_bytes = ocr.extract(file.read())
Compatibility
The old ReceiverExtractor class name is still available as an alias:
from onflow_awb_ocr import ReceiverExtractor
ocr = ReceiverExtractor()
result = ocr.extract("label.pdf")
Package Structure
extractor.py: publicOnflowAwbOcrclassinput.py: input preparation for paths, URLs, bytes, and binary streamstext_layer.py: PDF text-layer extraction strategiesocr.py: OCR fallback for scanned PDFs and imagespostprocess.py: address cleanuptypes.py,constants.py,utils.py: shared types, constants, and helpers
Publishing
GitHub Actions builds and publishes the package to PyPI on every push to main.
The repository must define this GitHub secret:
PYPI_API_TOKEN
PyPI does not allow replacing an existing version. If a commit on main does not
bump project.version in pyproject.toml, the publish step skips the existing
distribution.
Metadata
Release files for onflow-awb-ocr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| onflow_awb_ocr-0.1.0.tar.gz | 9.8 kB | Without provenance | Details for onflow_awb_ocr-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| onflow_awb_ocr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for onflow_awb_ocr-0.1.0-py3-none-any.whl |
Total release size: 21.3 kB
Release files / onflow_awb_ocr-0.1.0.tar.gz
| Download URL | onflow_awb_ocr-0.1.0.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6cad6d1d820e62c4a38dcfbc52c7e5d0b059ed60d74c26781c74ee5218ddcefd
|
|
BLAKE2b-256 checksum How to use checksums |
ca57593e46204b247ec3e6f09eb49318b034fc4bf49e9af5989ebea1b4e2d269
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / onflow_awb_ocr-0.1.0-py3-none-any.whl
| Download URL | onflow_awb_ocr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
024def625b6a8c9e3232b97a6e6bfa64f2ac07a916ab54085ad5e986824c9c07
|
|
BLAKE2b-256 checksum How to use checksums |
a5cacd83b3ee47f97ec5d7e9637d9931cc008aea6b16d38f5461af4d3e133b2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for onflow-awb-ocr 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.