stampbarcode
Duplicate a PDF with serial barcode stamps
Installation
Requires Python 3.10 or later.
pipx install stampbarcode
or
uv tool install stampbarcode
Usage
stampbarcode [--start N] [--number N] [--barwidth FLOAT] [--position inside|outside|left|right|top|bottom] [--offset OFFSET] [--output-dir DIR] file.pdf
For example, to make three numbered copies of an exam:
stampbarcode --start 1001 --number 3 --output-dir stamped exam.pdf
This writes stamped/exam-1001.pdf, stamped/exam-1002.pdf, and stamped/exam-1003.pdf.
By default, this produces files named <stem>-<code>.pdf in the current working directory.
Use --output-dir DIR to write generated files to a specific directory.
Existing files with the same names are overwritten without warning.
Each output file is a stamped copy using a Code39 barcode (with the number shown
as human-readable text), and --position controls where the barcode is placed.
The default is inside: left on recto pages and right on verso pages.
--barwidth controls the width of each barcode bar (default: 0.6).
Bar widths and offsets are measured in PDF points (1/72 inch).
Other position modes are outside, left, right, top, and bottom.
The first generated barcode is exactly --start, and --number controls how many
consecutive codes are produced.
Barcode Position Offsets
The --offset option allows fine-tuning the barcode position with format [+-]lateral[+-]normal:
-
Lateral offset: Moves the barcode perpendicular to its primary axis
- Positive values move right (in barcode coordinates)
- Negative values move left (in barcode coordinates)
-
Normal offset: Moves the barcode along its primary axis
- Positive values move up (in barcode coordinates)
- Negative values move down (in barcode coordinates)
Examples: --offset +10-5, --offset -3.5+2.1, --offset +0-15
Offset Behavior by Position
All offsets are relative to the barcode's orientation, not the physical page:
| Position | Edge | Lateral Effect | Normal Effect |
|---|---|---|---|
top |
top | moves horizontally right/left | moves vertically up/down |
bottom |
bottom | moves horizontally right/left | moves vertically up/down |
left / recto inside |
left | moves vertically down/up | moves horizontally right/left |
right / verso inside |
right | moves vertically up/down | moves horizontally left/right |
outside recto |
right | moves vertically up/down | moves horizontally left/right |
outside verso |
left | moves vertically down/up | moves horizontally right/left |
Intuition: Think of the barcode as having its own local coordinate system (lateral and normal axes). The offset moves the barcode within that system, and the effect on the page depends on the barcode's rotation.
Limitations
- The barcode is placed using each page's media box, assuming its origin is at the lower-left corner. Pages with a
/Rotateentry (common in scans), a shifted media box, or a smaller crop box may get a misplaced barcode. - Only Code 39 barcodes are supported, and the bar height and margin are fixed.
Development
Use the repo-local virtual environment for tests and editable installs:
python -m venv .venv
. .venv/bin/activate
python -m pip install -e '.[dev]'
python -m pytest -q
License
MIT. See LICENSE.
Metadata
Release files for stampbarcode 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 | |
|---|---|---|---|
| stampbarcode-0.1.0.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stampbarcode-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / stampbarcode-0.1.0.tar.gz
| Download URL | stampbarcode-0.1.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88bf0fb0fd8d77b113894c491b4610770230219b5a99153000da6447e1b89ab2
|
|
BLAKE2b-256 checksum How to use checksums |
61fe5a773a8b94737dd73c8707a831383b2140db566f2368838bb9b4da861f8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / stampbarcode-0.1.0-py3-none-any.whl
| Download URL | stampbarcode-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7abdfb9d6686f31da6c1a6ddf3ab369af3ab5c0bc0c8f11e1bdf2c76bade1b26
|
|
BLAKE2b-256 checksum How to use checksums |
19118c8beb081cdd3028c2a9eae792ac79bdd49c07317ded383f605e2868504e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency log