Registry / serialization / pdf417gen

pdf417gen

JSON →
library0.8.1pypypi✓ verified 84d ago

A pure Python library for generating PDF417 2D barcodes. Version 0.8.1 (latest) supports encoding text, bytes, and numbers into PDF417 barcodes, with output as PIL Images, SVG strings, or list of boolean rows. Requires Python >=3.8.

pip install pdf417gen
INSTALL
IMPORT
SIG · PDF417GEN
P
pdf417gen
serializationpythonv0.8.1
Install
2.3s avg
Import
128ms
Disk
36MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.132s · 37.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.3s · import 0.124s · 38MB
36MB installed
● package 36MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

encode
from pdf417gen import encode
Import encode function directly; no submodule.
render_image
from pdf417gen import render_image
Render barcode as a PIL Image.
render_svg
from pdf417gen import render_svg
Render barcode as an SVG string.
to_legacy_barcodes
from pdf417gen import to_legacy_barcodes
Convert to list of boolean rows for custom rendering.

Encode a string and render as image. Requires Pillow.

from pdf417gen import encode, render_image from PIL import Image # Encode a string into barcode codewords codes = encode('Hello, PDF417!') # Render as PIL Image (returns a PIL Image object) image = render_image(codes) # type: Image.Image image.save('barcode.png')
Debug
Known issues
gotchaThe function `render_image` returns a PIL Image, not a file path. You must save it explicitly with `image.save('file.png')`.
fix
Call `image.save('output.png')` or use `render_image(codes).save('output.png')`.
affects: all
gotchaInput must be a string, bytes, or an integer (single codeword). Passing a list of integers not as codewords will produce unexpected results.
fix
Pass a string (e.g., 'data') or bytes for binary data. Use `encode` which returns codewords.
affects: all
gotchaIn Python 3, the `encode` function expects a string by default. If you pass bytes, it tries to decode as utf-8; to encode raw bytes, convert to string appropriately.
fix
For binary data: `encode(data.decode('latin-1'))` or use `data` directly if it's a string.
affects: 0.5.0+
Errors
Common errors & fixes
NameError: name 'render_image' is not defined
Forgot to import render_image, or imported from wrong module.
fix
Use: `from pdf417gen import render_image`
ModuleNotFoundError: No module named 'PIL'
Pillow is required for render_image but not installed automatically.
fix
Install Pillow: `pip install Pillow`
pdf417gen.encode() got multiple values for argument 'columns'
Passed both positional and keyword argument for columns, or incorrect signature.
fix
Use keyword arguments: `encode('data', columns=5)` instead of positional.
Upgrade
Version history
0.8.1latest on PyPI · released Jan 23, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
pdf417gen — pip install pdf417gen · libregistry