pyStrich

pyStrich est un module rapide, écrit intégralement en Python pour générer des codes-barres 1D et 2D. Il prend en charge les symbologies Code 39, Code 128 (y compris GS1-128), EAN-13, ITF-14 (et 2 parmi 5 entrelacé), Data Matrix (y compris GS1 Data Matrix), QR Code, PDF417 et Aztec Code. Les huit produisent du PNG (via Pillow), du SVG et de l’EPS. Les formats 2D offrent en plus un rendu terminal et le DXF pour le marquage direct des pièces.

pyStrich est uniquement un encodeur : il ne lit pas les codes-barres.

Installation

$ pip install pyStrich

La sortie PNG dépend de Pillow ; les sorties SVG, EPS, DXF et terminal, non. Installez l’extra png pour garantir la présence de Pillow :

$ pip install "pyStrich[png]"

Démarrage rapide

from pystrich.datamatrix import DataMatrixData, DataMatrixEncoder

payload = DataMatrixData("https://github.com/mmulqueen/pyStrich", auto_encoding=True)
DataMatrixEncoder(payload).save_svg("datamatrix-example.svg")
Data Matrix encodant l'URL GitHub de pyStrich.

Un exemple minimal pour chacune des autres symbologies :

from pystrich.code39 import Code39Encoder
Code39Encoder("64755").save_svg("code39-example.svg")
Code-barres Code 39 encodant « 64755 ».
from pystrich.code128 import Code128Encoder
Code128Encoder("WDBCA45D2HA327260").save_svg("code128-example.svg")
Code-barres Code 128 encodant « WDBCA45D2HA327260 ».
from pystrich.ean13 import EAN13Encoder
EAN13Encoder("5050070007664").save_svg("ean13-example.svg")
Code-barres EAN-13 encodant « 5050070007664 ».
from pystrich.itf import ITF14Encoder
ITF14Encoder("1505007000766").save_svg("itf14-example.svg")
Code-barres ITF-14 encodant « 15050070007661 ».
from pystrich.qrcode import QRCodeEncoder
QRCodeEncoder("https://github.com/mmulqueen/pyStrich").save_svg("qrcode-example.svg")
Code QR encodant l'URL GitHub de pyStrich.
from pystrich.pdf417 import PDF417Encoder
PDF417Encoder("WDBCA45D2HA327260").save_svg("pdf417-example.svg")
PDF417 encodant « WDBCA45D2HA327260 ».
from pystrich.aztec import AztecEncoder
AztecEncoder("https://github.com/mmulqueen/pyStrich").save_svg("aztec-example.svg")
Aztec Code encodant l'URL GitHub de pyStrich.

Pour d’autres cas d’usage – servir des codes-barres en réponse à une requête web, générer en masse, composer sur une étiquette – voir Recettes.

Symbologies

Vous ne savez pas laquelle choisir ? Voir Choisir la bonne symbologie.

Guides

Référence

Historique

pyStrich était à l’origine un fork de huBarcode. huBarcode a été développé par HuDoRa à partir de 2007 au moins, et n’est plus actif depuis fin 2013. Method B Ltd a forké huBarcode sous le nom de pyStrich en 2015 pour assurer la prise en charge de Python 3 et poursuivre le développement. pyStrich a été considérablement enrichi au fil des ans et va bien au-delà d’un simple portage vers Python 3. En 2026, pyStrich est un paquet Python moderne, faisant pleinement usage du typage, du linting et d’une suite de tests complète.

Merci à l’équipe de HuDoRa pour la bibliothèque huBarcode d’origine dont pyStrich est issu.

Licence

Copyright various contributors to huBarcode, later pyStrich.
Main contributions are from HuDoRa from at least 2007 to 2013
Contributions since 2015 are from Method B Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Courier Prime (used to generate the glyph outlines embedded in
pystrich/_courier_glyphs.py for SVG/EPS labels) is distributed under the
SIL Open Font License, Version 1.1. The upstream license text is bundled
inline as the OFL_LICENSE constant in pystrich/_courier_glyphs.py and is
also available at courier_prime/OFL.txt in the source repository.