@@ -5,6 +5,10 @@ Code 39 is a 1D symbology widely used for industrial labelling. The default
55character set is uppercase letters, digits, space and ``-.$/+% ``; pass
66``full_ascii=True `` to encode any 7-bit character as a pair of symbols.
77
8+ .. code-block :: python
9+
10+ Code39Encoder(" 17 E North 32 St" , full_ascii = True ).save(" code39-address.png" )
11+
812 .. seealso ::
913
1014 `Code 39 on Wikipedia <https://en.wikipedia.org/wiki/Code_39 >`_ for
@@ -17,35 +21,19 @@ Example
1721
1822 from pystrich.code39 import Code39Encoder
1923
20- encoder = Code39Encoder(" PART-1234 " )
21- encoder.save (" code39-example.png " )
24+ encoder = Code39Encoder(" 64755 " )
25+ encoder.save_svg (" code39-example.svg " )
2226
23- .. image :: examples/code39-example.png
24- :alt: Code 39 barcode encoding "PART-1234 ".
27+ .. image :: examples/code39-example.svg
28+ :alt: Code 39 barcode encoding "64755 ".
2529
26- Sizing
27- ------
30+ Sizing, label, font and layout
31+ ------------------------------
2832
2933The ``bar_width `` argument to :meth: `~Code39Encoder.save ` and
3034:meth: `~Code39Encoder.get_imagedata ` sets the pixel width of the narrowest
3135bar (default ``3 ``).
3236
33- .. code-block :: python
34-
35- encoder = Code39Encoder(" PART-1234" )
36- encoder.save(" code39-wide.png" , bar_width = 6 )
37-
38- .. image :: examples/code39-wide.png
39- :alt: Code 39 barcode encoding "PART-1234" rendered with bar_width=6.
40-
41- .. seealso ::
42-
43- :doc: `printing ` for guidance on selecting ``bar_width `` for printed
44- output.
45-
46- Label, font and layout
47- ----------------------
48-
4937The ``options `` dict passed to :class: `Code39Encoder ` controls the
5038human-readable label and the surrounding layout. All keys are optional.
5139
@@ -64,6 +52,11 @@ human-readable label and the surrounding layout. All keys are optional.
6452``bottom_border ``
6553 Pixels of vertical space between the label and the bottom edge.
6654
55+ .. seealso ::
56+
57+ :doc: `printing ` for guidance on selecting ``bar_width `` for printed
58+ output.
59+
6760.. code-block :: python
6861
6962 options = {
@@ -73,42 +66,55 @@ human-readable label and the surrounding layout. All keys are optional.
7366 " ttf_fontsize" : 24 ,
7467 # "ttf_font": "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
7568 }
76- encoder = Code39Encoder(" PART-1234 " , options = options)
69+ encoder = Code39Encoder(" 64755 " , options = options)
7770 encoder.save(" code39-custom.png" , bar_width = 4 )
7871
7972 .. image :: examples/code39-custom.png
80- :alt: Code 39 barcode encoding "PART-1234" with a taller image and larger label.
73+ :alt: Code 39 barcode encoding "64755" with a taller image and larger label.
74+
75+ Output formats
76+ --------------
8177
8278SVG output
83- ----------
79+ ~~~~~~~~~~
8480
8581For embedding in web pages or any workflow that benefits from
8682resolution-independent output, use :meth: `~Code39Encoder.save_svg ` (or
8783:meth: `~Code39Encoder.get_svg ` to receive the SVG as a string).
8884
8985.. code-block :: python
9086
91- Code39Encoder(" PART-1234 " ).save_svg(" code39.svg" )
87+ Code39Encoder(" 64755 " ).save_svg(" code39.svg" )
9288
9389 .. image :: examples/code39-example.svg
94- :alt: SVG Code 39 barcode encoding "PART-1234 ".
90+ :alt: SVG Code 39 barcode encoding "64755 ".
9591
9692The SVG's ``viewBox `` is in module units (one narrow bar = one unit), while
9793``width `` and ``height `` scale by ``bar_width ``. The 10-module quiet zones
9894mandated by the standard are applied automatically on each side.
9995
10096.. versionadded :: 0.12
10197
98+ PNG output
99+ ~~~~~~~~~~
100+
101+ For raster output, use :meth: `~Code39Encoder.save ` to write a PNG file or
102+ :meth: `~Code39Encoder.get_imagedata ` to receive the raw PNG bytes.
103+
104+ .. code-block :: python
105+
106+ Code39Encoder(" 64755" ).save(" code39.png" )
107+
102108 EPS output
103- ----------
109+ ~~~~~~~~~~
104110
105111For embedding in LaTeX (``\includegraphics ``) or other vector print
106112workflows, use :meth: `~Code39Encoder.save_eps ` (or
107113:meth: `~Code39Encoder.get_eps ` to receive the EPS as a string).
108114
109115.. code-block :: python
110116
111- Code39Encoder(" PART-1234 " ).save_eps(" code39.eps" )
117+ Code39Encoder(" 64755 " ).save_eps(" code39.eps" )
112118
113119 The ``bar_width `` argument is the width of the narrowest bar in PostScript
114120points (1 point = 1/72 inch). The 10-module quiet zones are applied
0 commit comments