bce is a command-line tool that reads every barcode from a PDF and writes the results to a JSON file.
For each page of the input PDF, bce:
- Renders the page as a raster image at 300 DPI.
- Composites any transparent pixels onto a white background.
- Converts the image to grayscale luminance.
- Runs ZXing barcode detection across all supported formats (
TryHarder,TryRotate,TryDownscaleall enabled). - Blanks out every detected barcode region (replaces it with light blue) and repeats detection — up to five times per page — so that barcodes hidden behind or near other barcodes are also found.
- Collects all unique barcodes (deduplicated by content) and records their type and text.
The output is a JSON array — one entry per page — listing the page number and any barcodes found on that page.
bce <input-path> <output-path> [--intermediate <path>] [--escape-unicode]
| Argument | Description |
|---|---|
input-path |
Path to the PDF file to process. |
output-path |
Path where the extracted barcode JSON will be written. |
--intermediate, -i |
Optional directory for debug PNG output. Saves one image per page per detection pass so you can see which barcodes were found in which iteration. |
--escape-unicode |
Escape non-ASCII characters as \uXXXX in the JSON output. By default, Unicode characters are written as-is. |
[
{
"Page": 1,
"Barcodes": [
{ "Type": "QRCode", "Contents": "https://example.com" },
{ "Type": "Code128", "Contents": "ABC-12345" }
]
},
{
"Page": 2,
"Barcodes": []
}
]Requires .NET 9. On macOS with Homebrew:
brew install dotnet@9
dotnet buildThe included code.sh script sets up the correct DOTNET_ROOT when dotnet@9 is installed via Homebrew and opens the project in VS Code.
See THIRD-PARTY-NOTICES.md for dependency license and redistribution notices.
This project is built on three open-source libraries:
-
ZXingCpp — Apache License 2.0
.NET binding for zxing-cpp, a C++ port of the ZXing ("Zebra Crossing") barcode scanning library. Used to detect and decode barcodes from grayscale image data. -
Docnet.Core — MIT License
.NET wrapper around PDFium, Google's PDF rendering engine. Used to open PDF files, iterate pages, and render each page to a pixel buffer. -
SkiaSharp — MIT License
.NET binding for Skia, Google's 2D graphics library. Used to encode intermediate debug images as PNG files.