Scan PDF for barcodes and split
Project description
pdfxcb
Split a PDF
pdfxcb splits a PDF using pages with barcodes as delimiters or after every Nth page.
Splitting a PDF using barcodes
Any page in the input PDF containing a barcode is potentially a "barcode sheet". Each barcode sheet, and those pages succeeding that page and preceding the next barcode sheet, comprise a single set of pages output as a discrete PDF file.
Each output file is named, by default, as <encoded string>-<index>.pdf where <encoded string> is the content encoded by the barcode on the barcode sheet and <index> is the page number of the barcode sheet relative to the input PDF. The page number is formatted as a three-digit page number (e.g., 001 or 023) unless the page number exceeds 999. Page numbering begins at one.
Example
pdfxcb -r 0.2 0 1 0.3 -l 0 -d ./outputdir -f ./pdfxcb.log /path/to/scans.pdf
Invoking with -r causes the program to attempt to split prior to each page with a barcode in the specified page region. The arguments following the -r flag specify two points as x1 y1 x2 y2. The values are percentages (0 to 1.0) where (0,0) represents the top left corner of the page. These points define the scan region as a rectangle.
The above example scans roughly the upper right third of each page in the input file, /path/to/scans.pdf. The output files are written to ./outputdir. A log is generated at ./pdfxcb.log.
Split every N pages
Example
Reads as input /input/file.pdf and splits after every 14 pages.
pdfxcb -e 14 -d /path/output/dir /input/file.pdf
Invoking from the shell
Use pdfxcb --help.
Invoking from within Python
>>> pdfxcb.lg.getLogger().setLevel(pdfxcb.lg.DEBUG)
>>> pdfxcb.pdfxcb("/home/joejoe/src/pdfxcb/testing-sandbox/pdfxcb/test-doc-01/test-doc-01.pdf","/home/joejoe/src/pdfxcb/testing-sandbox/pdfxcb/test-doc-01/",None,False)
Logging
A successful "run" should generate at least 3 log messages, each as a separate line in the log file: an initial log message (code 3), the results of analysis and burst/splitting (code 40), and a final log message (code 2).
Example of log file content
{"microsec": 229757, "message": "Initial log message", "code": 3, "id": "96f08ca4-1746-11e8-936f-9840bb275139", "time": 1519245258}
{"files": ["/tmp/123ABCabc-001.pdf", "/tmp/1234567890128-003.pdf"], "code": 40, "microsec": 402458, "time": 1520018355, "message": ["Analysis and burst completed"], "data": {"indices": [1, 3, 6], "barcodes": ["123ABCabc", "1234567890128"]}}
{"microsec": 791009, "message": "Scan and analysis complete", "code": 2, "time": 1519245261}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdfxcb-3.0.0.tar.gz.
File metadata
- Download URL: pdfxcb-3.0.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.5 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a587842dda178f5e4f58cb0b7938170f57edd4eac927139d5f7e73ab5914673
|
|
| MD5 |
8d497895d3b2252db34665703c755a41
|
|
| BLAKE2b-256 |
a0c982fbe8190fb15e526d27899e3692d28959eba7f2377b9438d2bb1771df59
|
File details
Details for the file pdfxcb-3.0.0-py3-none-any.whl.
File metadata
- Download URL: pdfxcb-3.0.0-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.5 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9a5de66748d3abc1346bfe78beec4c8c1e12dedf8419fcfef05ced42203a0c1
|
|
| MD5 |
64b83f89ac60c43f4938952ccd2a48d8
|
|
| BLAKE2b-256 |
e8809c4a9c428e8708d7aa3d7a5abf72d1a3f55a312595a611a7a2ed14bffe68
|