bookbarcode 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bookbarcode-0.4.1/CHANGELOG.md +103 -0
- bookbarcode-0.4.1/LICENSE +21 -0
- bookbarcode-0.4.1/MANIFEST.in +12 -0
- bookbarcode-0.4.1/PKG-INFO +242 -0
- bookbarcode-0.4.1/README.md +220 -0
- bookbarcode-0.4.1/SKILL.yaml +153 -0
- bookbarcode-0.4.1/USE_TOOL.md +387 -0
- bookbarcode-0.4.1/bookbarcode/__init__.py +47 -0
- bookbarcode-0.4.1/bookbarcode/barcode.py +84 -0
- bookbarcode-0.4.1/bookbarcode/cli.py +77 -0
- bookbarcode-0.4.1/bookbarcode/ean13.py +67 -0
- bookbarcode-0.4.1/bookbarcode/geometry.py +138 -0
- bookbarcode-0.4.1/bookbarcode/io.py +68 -0
- bookbarcode-0.4.1/bookbarcode/isbn.py +74 -0
- bookbarcode-0.4.1/bookbarcode/layout.py +438 -0
- bookbarcode-0.4.1/bookbarcode/py.typed +0 -0
- bookbarcode-0.4.1/bookbarcode/renderers/__init__.py +6 -0
- bookbarcode-0.4.1/bookbarcode/renderers/pdf.py +110 -0
- bookbarcode-0.4.1/bookbarcode/renderers/svg.py +92 -0
- bookbarcode-0.4.1/bookbarcode/verification/__init__.py +7 -0
- bookbarcode-0.4.1/bookbarcode/verification/pdf.py +395 -0
- bookbarcode-0.4.1/bookbarcode/verification/result.py +22 -0
- bookbarcode-0.4.1/bookbarcode/verification/svg.py +111 -0
- bookbarcode-0.4.1/bookbarcode.egg-info/PKG-INFO +242 -0
- bookbarcode-0.4.1/bookbarcode.egg-info/SOURCES.txt +42 -0
- bookbarcode-0.4.1/bookbarcode.egg-info/dependency_links.txt +1 -0
- bookbarcode-0.4.1/bookbarcode.egg-info/entry_points.txt +2 -0
- bookbarcode-0.4.1/bookbarcode.egg-info/requires.txt +4 -0
- bookbarcode-0.4.1/bookbarcode.egg-info/top_level.txt +1 -0
- bookbarcode-0.4.1/docs/KDY-REFERANS-NOTLARI.md +69 -0
- bookbarcode-0.4.1/docs/KDY-REFERENCE-NOTES.md +69 -0
- bookbarcode-0.4.1/docs/KULLANIM.md +410 -0
- bookbarcode-0.4.1/docs/MEASUREMENT-DAG.md +258 -0
- bookbarcode-0.4.1/docs/USAGE.md +405 -0
- bookbarcode-0.4.1/docs/assets/bookbarcode-preview.svg +55 -0
- bookbarcode-0.4.1/examples/basic_usage.py +23 -0
- bookbarcode-0.4.1/examples/package_usage.py +27 -0
- bookbarcode-0.4.1/isbn_barcode.py +7 -0
- bookbarcode-0.4.1/pyproject.toml +42 -0
- bookbarcode-0.4.1/setup.cfg +4 -0
- bookbarcode-0.4.1/tests/test_cli.py +42 -0
- bookbarcode-0.4.1/tests/test_library.py +385 -0
- bookbarcode-0.4.1/tests/test_tool.py +259 -0
- bookbarcode-0.4.1/tool.py +375 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to BookBarcode are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.4.1] - 2026-09-20
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Added a project changelog reconstructed from declared package versions,
|
|
15
|
+
release tags, and commit history.
|
|
16
|
+
- Added GitHub Actions CI across Python 3.9-3.13 on Linux, with a gated
|
|
17
|
+
distribution build and metadata check.
|
|
18
|
+
- Added a generated barcode preview using the example ISBN from the
|
|
19
|
+
International ISBN Agency's Users' Manual.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Reworked README onboarding around explicit CLI, Python API, and agent entry
|
|
24
|
+
points, with complete PyPI and editable-development installation paths.
|
|
25
|
+
- Replaced project-specific ISBN examples and test fixtures with published
|
|
26
|
+
reference examples, and made PyPI the primary installation path.
|
|
27
|
+
|
|
28
|
+
## [0.4.0] - 2026-09-02
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- Added the typed `LayoutSpec -> resolve_layout() -> ResolvedBarcodeLayout ->
|
|
33
|
+
BarcodeGeometry` measurement pipeline.
|
|
34
|
+
- Added a canonical measurement dependency DAG documenting derivation and
|
|
35
|
+
constraint relationships.
|
|
36
|
+
- Added public geometry and resolved-layout types for callers that need an
|
|
37
|
+
explicit, fully resolved representation.
|
|
38
|
+
- Added stronger PDF artifact inspection for page dimensions, process-black
|
|
39
|
+
commands, barcode modules, guard bars, human-readable digits, and physical
|
|
40
|
+
geometry.
|
|
41
|
+
- Added negative tests for tampered SVG and PDF artifacts.
|
|
42
|
+
- Added end-to-end JSON adapter tests for generation, verification, path,
|
|
43
|
+
overwrite, and invalid-input behavior.
|
|
44
|
+
- Added `USE_TOOL.md` as the agent operating procedure and expanded
|
|
45
|
+
`SKILL.yaml` as the canonical machine-readable tool contract.
|
|
46
|
+
- Added English usage and KDY reference documentation alongside the Turkish
|
|
47
|
+
guides.
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
|
|
51
|
+
- Both SVG and PDF renderers now consume the same resolved barcode geometry.
|
|
52
|
+
- Layout resolution now rejects non-standard geometry that violates mandatory
|
|
53
|
+
module, quiet-zone, guard-extension, or vertical-layout constraints.
|
|
54
|
+
- SVG and PDF verification calculations are more independent from renderer
|
|
55
|
+
implementation helpers.
|
|
56
|
+
- README and user guides now explain output selection, custom layouts,
|
|
57
|
+
overwrite policy, assigned ISBN hyphenation, and production preflight.
|
|
58
|
+
- Package metadata, licensing, source manifests, and development dependencies
|
|
59
|
+
were prepared for public distribution.
|
|
60
|
+
|
|
61
|
+
### Safety
|
|
62
|
+
|
|
63
|
+
- Bundle writes now perform preflight checks before producing either output,
|
|
64
|
+
reducing avoidable partial SVG/PDF bundles.
|
|
65
|
+
- Generated artifacts are verified before atomic replacement of their target
|
|
66
|
+
files.
|
|
67
|
+
|
|
68
|
+
## [0.3.0] - 2026-08-31
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- Introduced the reusable typed `bookbarcode` Python package.
|
|
73
|
+
- Added immutable `Barcode` and `BarcodeLayout` public APIs.
|
|
74
|
+
- Added ISBN-13 normalization and checksum validation for `978` and `979`
|
|
75
|
+
prefixes.
|
|
76
|
+
- Added deterministic 95-module EAN-13 encoding and shared millimetre-based
|
|
77
|
+
geometry.
|
|
78
|
+
- Added editable SVG and process-black CMYK PDF renderers.
|
|
79
|
+
- Added serialized artifact verification for SVG and PDF outputs.
|
|
80
|
+
- Added the `bookbarcode` human CLI and JSON agent-tool entrypoint.
|
|
81
|
+
- Added normal 35 x 19 mm and minimum 26 x 14 mm KDY presets.
|
|
82
|
+
- Added validated atomic file writes with explicit overwrite protection.
|
|
83
|
+
- Added package, CLI, and adapter test suites, type information, examples,
|
|
84
|
+
Turkish documentation, and agent maintenance guidance.
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
|
|
88
|
+
- Replaced the original single-file prototype with separated ISBN, EAN,
|
|
89
|
+
layout, geometry, rendering, verification, I/O, CLI, and adapter modules.
|
|
90
|
+
|
|
91
|
+
## [0.1.0] - 2026-08-25
|
|
92
|
+
|
|
93
|
+
### Added
|
|
94
|
+
|
|
95
|
+
- Added the initial standalone ISBN-13/EAN-13 SVG generator prototype.
|
|
96
|
+
- Added basic physical barcode sizing, guard bars, quiet zones, visible ISBN
|
|
97
|
+
text, and CMYK intent metadata.
|
|
98
|
+
|
|
99
|
+
[Unreleased]: https://github.com/Aues12/BookBarcode/compare/v0.4.1...HEAD
|
|
100
|
+
[0.4.1]: https://github.com/Aues12/BookBarcode/releases/tag/v0.4.1
|
|
101
|
+
[0.4.0]: https://github.com/Aues12/BookBarcode/releases/tag/v0.4.0
|
|
102
|
+
[0.3.0]: https://github.com/Aues12/BookBarcode/commit/4c047fd04b94878b9d242302b8d7676389ccc0a5
|
|
103
|
+
[0.1.0]: https://github.com/Aues12/BookBarcode/commit/2e80d18b6c895f2cc99d724e0a4d97e256daccfc
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aues12
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include CHANGELOG.md
|
|
3
|
+
include USE_TOOL.md
|
|
4
|
+
include LICENSE
|
|
5
|
+
include pyproject.toml
|
|
6
|
+
include isbn_barcode.py
|
|
7
|
+
include tool.py
|
|
8
|
+
include SKILL.yaml
|
|
9
|
+
recursive-include bookbarcode *.py py.typed
|
|
10
|
+
recursive-include docs *.md *.svg
|
|
11
|
+
recursive-include examples *.py
|
|
12
|
+
recursive-include tests *.py
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bookbarcode
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Deterministic, print-ready ISBN-13 barcode generation for SVG and CMYK PDF
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/Aues12/BookBarcode
|
|
7
|
+
Project-URL: Repository, https://github.com/Aues12/BookBarcode
|
|
8
|
+
Project-URL: Issues, https://github.com/Aues12/BookBarcode/issues
|
|
9
|
+
Keywords: barcode,ean-13,isbn,pdf,svg
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
14
|
+
Classifier: Typing :: Typed
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
20
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# BookBarcode
|
|
24
|
+
|
|
25
|
+
[](https://github.com/Aues12/BookBarcode/actions/workflows/CI.yml)
|
|
26
|
+
|
|
27
|
+
BookBarcode generates deterministic ISBN-13/EAN-13 barcodes for books.
|
|
28
|
+
It creates editable SVG files and print-ready PDF files, and checks each
|
|
29
|
+
artifact before writing it.
|
|
30
|
+
|
|
31
|
+
- **PDF** is the recommended final format for printing. It uses true process
|
|
32
|
+
black: `C:0 M:0 Y:0 K:100`.
|
|
33
|
+
- **SVG** is useful for vector editing and preview. It includes CMYK intent
|
|
34
|
+
metadata, although colour handling ultimately depends on the SVG application.
|
|
35
|
+
|
|
36
|
+
The package has no runtime third-party dependencies and supports Python 3.9+.
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+
*Example generated from the ISBN used in the International ISBN Agency's
|
|
41
|
+
[Users' Manual](https://www.isbn-international.org/content/isbn-users-manual/29).*
|
|
42
|
+
|
|
43
|
+
## Choose an entrypoint
|
|
44
|
+
|
|
45
|
+
| I want to... | Start with |
|
|
46
|
+
|---|---|
|
|
47
|
+
| Generate a barcode from a terminal | [Human CLI](#quick-start) |
|
|
48
|
+
| Use BookBarcode from Python | [Python API](#python-api) |
|
|
49
|
+
| Call BookBarcode from an agent | [JSON agent interface](#agent-tools-json-interface) |
|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
Install the current release from PyPI:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python3 -m pip install "bookbarcode==0.4.1"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Generate both formats with a valid ISBN-13:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
bookbarcode 9789295055124 \
|
|
63
|
+
--display "ISBN 978-92-95055-12-4"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This creates and verifies these files in the current directory:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
book-barcode.svg
|
|
70
|
+
book-barcode.pdf
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The command refuses to replace an existing file unless you add `--overwrite`.
|
|
74
|
+
It writes a temporary sibling, verifies it, then atomically installs it at the
|
|
75
|
+
target path.
|
|
76
|
+
|
|
77
|
+
For an editable development installation, clone the repository first:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
git clone https://github.com/Aues12/BookBarcode.git
|
|
81
|
+
cd BookBarcode
|
|
82
|
+
python3 -m pip install -e .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
You can also run the command from this repository without installing it:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
python3 -m bookbarcode.cli 9789295055124 \
|
|
89
|
+
--display "ISBN 978-92-95055-12-4"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Common tasks
|
|
93
|
+
|
|
94
|
+
Create a print-ready PDF at a chosen path:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
bookbarcode 9789295055124 \
|
|
98
|
+
--format pdf \
|
|
99
|
+
--output output/book-barcode
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Use the smallest bundled layout when space is constrained:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
bookbarcode 9789295055124 \
|
|
106
|
+
--preset minimum \
|
|
107
|
+
--output output/small-book-barcode
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Use assigned ISBN hyphenation in the visible heading:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
bookbarcode 9780306406157 \
|
|
114
|
+
--display "ISBN 978-0-306-40615-7" \
|
|
115
|
+
--output output/book-barcode
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Without `--display`, BookBarcode uses a readable `3-3-3-3-1` fallback. This is
|
|
119
|
+
not an assertion about official ISBN registrant ranges; provide the assigned
|
|
120
|
+
hyphenation when it matters.
|
|
121
|
+
|
|
122
|
+
## Layout and output
|
|
123
|
+
|
|
124
|
+
| Preset | Dimensions | Best for |
|
|
125
|
+
|---|---:|---|
|
|
126
|
+
| `normal` (default) | 35 × 19 mm | Typical book barcodes |
|
|
127
|
+
| `minimum` | 26 × 14 mm | Space-constrained covers |
|
|
128
|
+
|
|
129
|
+
By default, BookBarcode writes both SVG and PDF. Use `--format svg` or
|
|
130
|
+
`--format pdf` to select one. `--output` sets the base path, so
|
|
131
|
+
`--output output/barcode` produces `output/barcode.svg` and/or
|
|
132
|
+
`output/barcode.pdf`; the directory must already exist.
|
|
133
|
+
|
|
134
|
+
Custom total dimensions, data-bar height, and either shared or independent
|
|
135
|
+
side margins are available. The detailed commands and the full option reference
|
|
136
|
+
are in the [English user guide](docs/USAGE.md). Their mandatory formulas,
|
|
137
|
+
dependencies, and constraints are defined by the
|
|
138
|
+
[measurement dependency DAG](docs/MEASUREMENT-DAG.md).
|
|
139
|
+
|
|
140
|
+
## Python API
|
|
141
|
+
|
|
142
|
+
Generate content without writing files:
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
from bookbarcode import Barcode
|
|
146
|
+
|
|
147
|
+
barcode = Barcode("9789295055124")
|
|
148
|
+
svg_text = barcode.to_svg()
|
|
149
|
+
pdf_bytes = barcode.to_pdf()
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Write verified artifacts explicitly:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from bookbarcode import Barcode, BarcodeLayout
|
|
156
|
+
|
|
157
|
+
layout = BarcodeLayout(
|
|
158
|
+
width_mm=38,
|
|
159
|
+
height_mm=20,
|
|
160
|
+
side_margin_mm=3.8,
|
|
161
|
+
bar_height_mm=12.5,
|
|
162
|
+
)
|
|
163
|
+
barcode = Barcode(
|
|
164
|
+
"9789295055124",
|
|
165
|
+
display_text="ISBN 978-92-95055-12-4",
|
|
166
|
+
layout=layout,
|
|
167
|
+
)
|
|
168
|
+
barcode.write_svg("book-barcode.svg")
|
|
169
|
+
barcode.write_pdf("book-barcode.pdf")
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
One module (`X`) is the narrowest EAN-13 bar/space unit. Custom margins are
|
|
173
|
+
accepted only when they preserve quiet zones of at least `11X` on the left and
|
|
174
|
+
`7X` on the right.
|
|
175
|
+
|
|
176
|
+
For explicit intent/resolution separation, use the typed measurement pipeline:
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from bookbarcode import LayoutSpec, build_barcode_geometry, resolve_layout
|
|
180
|
+
|
|
181
|
+
spec = LayoutSpec.from_preset("normal", side_margin_mm=3.5)
|
|
182
|
+
resolved = resolve_layout(spec)
|
|
183
|
+
geometry = build_barcode_geometry(
|
|
184
|
+
"9789295055124",
|
|
185
|
+
"ISBN 978-92-95055-12-4",
|
|
186
|
+
resolved,
|
|
187
|
+
)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`resolved` contains no optional measurements. `geometry` contains the complete
|
|
191
|
+
title, bar, and human-readable digit positions consumed by both renderers.
|
|
192
|
+
|
|
193
|
+
## Agent-tools JSON interface
|
|
194
|
+
|
|
195
|
+
Agent tools can use BookBarcode as a tool by sending a JSON request envelope to
|
|
196
|
+
`isbn_barcode.py` over standard input. The adapter translates that request to
|
|
197
|
+
the same package API used by Python and the CLI; it does not implement barcode
|
|
198
|
+
rules independently.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
printf '%s' '{
|
|
202
|
+
"operation": "write_barcode",
|
|
203
|
+
"params": {
|
|
204
|
+
"isbn": "9789295055124",
|
|
205
|
+
"output_base": "/tmp/book-barcode",
|
|
206
|
+
"layout": {"preset": "normal"}
|
|
207
|
+
}
|
|
208
|
+
}' | python3 isbn_barcode.py
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Supported operations are `generate_svg`, `write_svg`, `write_pdf`,
|
|
212
|
+
`write_barcode`, `verify_svg`, and `verify_pdf`. Agents and runtimes should read
|
|
213
|
+
the [tool usage procedure](USE_TOOL.md); [SKILL.yaml](SKILL.yaml) is the
|
|
214
|
+
canonical local machine-readable manifest.
|
|
215
|
+
|
|
216
|
+
## Documentation
|
|
217
|
+
|
|
218
|
+
- [Changelog](CHANGELOG.md) — release history and notable changes by version.
|
|
219
|
+
- [English user guide](docs/USAGE.md) — installation, complete CLI reference,
|
|
220
|
+
custom layouts, printing guidance, common errors, and examples.
|
|
221
|
+
- [Türkçe kullanım kılavuzu](docs/KULLANIM.md)
|
|
222
|
+
- [Agent tool usage procedure](USE_TOOL.md)
|
|
223
|
+
- [Canonical measurement dependency DAG](docs/MEASUREMENT-DAG.md)
|
|
224
|
+
- [KDY size and colour reference notes](docs/KDY-REFERENCE-NOTES.md)
|
|
225
|
+
- [KDY ölçü ve renk referans notları](docs/KDY-REFERANS-NOTLARI.md)
|
|
226
|
+
|
|
227
|
+
## Quality and printing
|
|
228
|
+
|
|
229
|
+
BookBarcode verifies serialized SVG and PDF dimensions, barcode modules, guard
|
|
230
|
+
bars, readable ISBN digits, physical geometry, and colour intent. PDF checks
|
|
231
|
+
parse the content stream rather than trusting the renderer's input geometry.
|
|
232
|
+
For production, keep quiet zones clear, do not scale the barcode
|
|
233
|
+
non-proportionally or rasterize it, and scan a printed sample after printer
|
|
234
|
+
preflight.
|
|
235
|
+
|
|
236
|
+
Run the test suite from the repository root:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
python3 -m unittest discover -s tests -v
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
BookBarcode is released under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# BookBarcode
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Aues12/BookBarcode/actions/workflows/CI.yml)
|
|
4
|
+
|
|
5
|
+
BookBarcode generates deterministic ISBN-13/EAN-13 barcodes for books.
|
|
6
|
+
It creates editable SVG files and print-ready PDF files, and checks each
|
|
7
|
+
artifact before writing it.
|
|
8
|
+
|
|
9
|
+
- **PDF** is the recommended final format for printing. It uses true process
|
|
10
|
+
black: `C:0 M:0 Y:0 K:100`.
|
|
11
|
+
- **SVG** is useful for vector editing and preview. It includes CMYK intent
|
|
12
|
+
metadata, although colour handling ultimately depends on the SVG application.
|
|
13
|
+
|
|
14
|
+
The package has no runtime third-party dependencies and supports Python 3.9+.
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
*Example generated from the ISBN used in the International ISBN Agency's
|
|
19
|
+
[Users' Manual](https://www.isbn-international.org/content/isbn-users-manual/29).*
|
|
20
|
+
|
|
21
|
+
## Choose an entrypoint
|
|
22
|
+
|
|
23
|
+
| I want to... | Start with |
|
|
24
|
+
|---|---|
|
|
25
|
+
| Generate a barcode from a terminal | [Human CLI](#quick-start) |
|
|
26
|
+
| Use BookBarcode from Python | [Python API](#python-api) |
|
|
27
|
+
| Call BookBarcode from an agent | [JSON agent interface](#agent-tools-json-interface) |
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
Install the current release from PyPI:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
python3 -m pip install "bookbarcode==0.4.1"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Generate both formats with a valid ISBN-13:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
bookbarcode 9789295055124 \
|
|
41
|
+
--display "ISBN 978-92-95055-12-4"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This creates and verifies these files in the current directory:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
book-barcode.svg
|
|
48
|
+
book-barcode.pdf
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The command refuses to replace an existing file unless you add `--overwrite`.
|
|
52
|
+
It writes a temporary sibling, verifies it, then atomically installs it at the
|
|
53
|
+
target path.
|
|
54
|
+
|
|
55
|
+
For an editable development installation, clone the repository first:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
git clone https://github.com/Aues12/BookBarcode.git
|
|
59
|
+
cd BookBarcode
|
|
60
|
+
python3 -m pip install -e .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
You can also run the command from this repository without installing it:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python3 -m bookbarcode.cli 9789295055124 \
|
|
67
|
+
--display "ISBN 978-92-95055-12-4"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Common tasks
|
|
71
|
+
|
|
72
|
+
Create a print-ready PDF at a chosen path:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
bookbarcode 9789295055124 \
|
|
76
|
+
--format pdf \
|
|
77
|
+
--output output/book-barcode
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Use the smallest bundled layout when space is constrained:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
bookbarcode 9789295055124 \
|
|
84
|
+
--preset minimum \
|
|
85
|
+
--output output/small-book-barcode
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Use assigned ISBN hyphenation in the visible heading:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
bookbarcode 9780306406157 \
|
|
92
|
+
--display "ISBN 978-0-306-40615-7" \
|
|
93
|
+
--output output/book-barcode
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Without `--display`, BookBarcode uses a readable `3-3-3-3-1` fallback. This is
|
|
97
|
+
not an assertion about official ISBN registrant ranges; provide the assigned
|
|
98
|
+
hyphenation when it matters.
|
|
99
|
+
|
|
100
|
+
## Layout and output
|
|
101
|
+
|
|
102
|
+
| Preset | Dimensions | Best for |
|
|
103
|
+
|---|---:|---|
|
|
104
|
+
| `normal` (default) | 35 × 19 mm | Typical book barcodes |
|
|
105
|
+
| `minimum` | 26 × 14 mm | Space-constrained covers |
|
|
106
|
+
|
|
107
|
+
By default, BookBarcode writes both SVG and PDF. Use `--format svg` or
|
|
108
|
+
`--format pdf` to select one. `--output` sets the base path, so
|
|
109
|
+
`--output output/barcode` produces `output/barcode.svg` and/or
|
|
110
|
+
`output/barcode.pdf`; the directory must already exist.
|
|
111
|
+
|
|
112
|
+
Custom total dimensions, data-bar height, and either shared or independent
|
|
113
|
+
side margins are available. The detailed commands and the full option reference
|
|
114
|
+
are in the [English user guide](docs/USAGE.md). Their mandatory formulas,
|
|
115
|
+
dependencies, and constraints are defined by the
|
|
116
|
+
[measurement dependency DAG](docs/MEASUREMENT-DAG.md).
|
|
117
|
+
|
|
118
|
+
## Python API
|
|
119
|
+
|
|
120
|
+
Generate content without writing files:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from bookbarcode import Barcode
|
|
124
|
+
|
|
125
|
+
barcode = Barcode("9789295055124")
|
|
126
|
+
svg_text = barcode.to_svg()
|
|
127
|
+
pdf_bytes = barcode.to_pdf()
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Write verified artifacts explicitly:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from bookbarcode import Barcode, BarcodeLayout
|
|
134
|
+
|
|
135
|
+
layout = BarcodeLayout(
|
|
136
|
+
width_mm=38,
|
|
137
|
+
height_mm=20,
|
|
138
|
+
side_margin_mm=3.8,
|
|
139
|
+
bar_height_mm=12.5,
|
|
140
|
+
)
|
|
141
|
+
barcode = Barcode(
|
|
142
|
+
"9789295055124",
|
|
143
|
+
display_text="ISBN 978-92-95055-12-4",
|
|
144
|
+
layout=layout,
|
|
145
|
+
)
|
|
146
|
+
barcode.write_svg("book-barcode.svg")
|
|
147
|
+
barcode.write_pdf("book-barcode.pdf")
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
One module (`X`) is the narrowest EAN-13 bar/space unit. Custom margins are
|
|
151
|
+
accepted only when they preserve quiet zones of at least `11X` on the left and
|
|
152
|
+
`7X` on the right.
|
|
153
|
+
|
|
154
|
+
For explicit intent/resolution separation, use the typed measurement pipeline:
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from bookbarcode import LayoutSpec, build_barcode_geometry, resolve_layout
|
|
158
|
+
|
|
159
|
+
spec = LayoutSpec.from_preset("normal", side_margin_mm=3.5)
|
|
160
|
+
resolved = resolve_layout(spec)
|
|
161
|
+
geometry = build_barcode_geometry(
|
|
162
|
+
"9789295055124",
|
|
163
|
+
"ISBN 978-92-95055-12-4",
|
|
164
|
+
resolved,
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`resolved` contains no optional measurements. `geometry` contains the complete
|
|
169
|
+
title, bar, and human-readable digit positions consumed by both renderers.
|
|
170
|
+
|
|
171
|
+
## Agent-tools JSON interface
|
|
172
|
+
|
|
173
|
+
Agent tools can use BookBarcode as a tool by sending a JSON request envelope to
|
|
174
|
+
`isbn_barcode.py` over standard input. The adapter translates that request to
|
|
175
|
+
the same package API used by Python and the CLI; it does not implement barcode
|
|
176
|
+
rules independently.
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
printf '%s' '{
|
|
180
|
+
"operation": "write_barcode",
|
|
181
|
+
"params": {
|
|
182
|
+
"isbn": "9789295055124",
|
|
183
|
+
"output_base": "/tmp/book-barcode",
|
|
184
|
+
"layout": {"preset": "normal"}
|
|
185
|
+
}
|
|
186
|
+
}' | python3 isbn_barcode.py
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Supported operations are `generate_svg`, `write_svg`, `write_pdf`,
|
|
190
|
+
`write_barcode`, `verify_svg`, and `verify_pdf`. Agents and runtimes should read
|
|
191
|
+
the [tool usage procedure](USE_TOOL.md); [SKILL.yaml](SKILL.yaml) is the
|
|
192
|
+
canonical local machine-readable manifest.
|
|
193
|
+
|
|
194
|
+
## Documentation
|
|
195
|
+
|
|
196
|
+
- [Changelog](CHANGELOG.md) — release history and notable changes by version.
|
|
197
|
+
- [English user guide](docs/USAGE.md) — installation, complete CLI reference,
|
|
198
|
+
custom layouts, printing guidance, common errors, and examples.
|
|
199
|
+
- [Türkçe kullanım kılavuzu](docs/KULLANIM.md)
|
|
200
|
+
- [Agent tool usage procedure](USE_TOOL.md)
|
|
201
|
+
- [Canonical measurement dependency DAG](docs/MEASUREMENT-DAG.md)
|
|
202
|
+
- [KDY size and colour reference notes](docs/KDY-REFERENCE-NOTES.md)
|
|
203
|
+
- [KDY ölçü ve renk referans notları](docs/KDY-REFERANS-NOTLARI.md)
|
|
204
|
+
|
|
205
|
+
## Quality and printing
|
|
206
|
+
|
|
207
|
+
BookBarcode verifies serialized SVG and PDF dimensions, barcode modules, guard
|
|
208
|
+
bars, readable ISBN digits, physical geometry, and colour intent. PDF checks
|
|
209
|
+
parse the content stream rather than trusting the renderer's input geometry.
|
|
210
|
+
For production, keep quiet zones clear, do not scale the barcode
|
|
211
|
+
non-proportionally or rasterize it, and scan a printed sample after printer
|
|
212
|
+
preflight.
|
|
213
|
+
|
|
214
|
+
Run the test suite from the repository root:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
python3 -m unittest discover -s tests -v
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
BookBarcode is released under the [MIT License](LICENSE).
|