Barcode
The barcode extension provides barcode rendering. Barcode macros can be specified using blocks, block macros, or inline macros using one of the following templates.
// Barcode block
[<type>, <attributes>] (1) (2)
----
<content> (3)
----
// Barcode block macro
<type>::<content>[<attributes>]
// Barcode inline macro
<type>:<content>[<attributes>]
1 | Type barcode type. One of bookland , codabar , code25 , code25iata , code25interleaved , code39 , code93 , code128 , code128a , code128b , code128c , ean8 , ean13 , gs1_128 , qrcode , or upca . |
2 | Attributes |
3 | The content to encode in the barcode |
By default, the content
field of the barcode macros will be interpreted as the barcode content.
This works fine for simple barcodes, but for complex data (e.g., a vCard encoded as a QR code) this is not practical.
If the external
attribute is set on a barcode macro, the target is interpreted as a file path.
The barcode content will then be obtained by reading the contents of the referenced file.
Example
Barcdodes can be written codabar:A31117013206375A[png, height=10] inline or as blocks. [qrcode, format="png", xdim=4] .... Hello World! ....
Barcode can be written inline or as blocks.
Installation
-
All barcodes types except QR codes require the barby Ruby gem
-
QR codes requires the rqrcode Ruby gem
-
PNG image output requires the chunky_png gem
Each of these dependencies will automatically get loaded as needed.
It is not necessary to require these manually using the -r
Asciidoctor CLI option.
Attributes
Name | Default value | Description |
---|---|---|
external |
false |
When set to true the target of a barcode macro is interpreted as an external source file instead of as the contents of the barcode |
height |
100 |
The height of the bars. (1D only, 2D uses ydim) |
xdim |
1 |
The width of the narrowest bar in a barcode. Thicker bars are multiples of the xdim. |
ydim |
Same as xdim |
This is the same as xdim, but for the height of the blocks in a 2D barcode. |
margin |
10 |
The width of the quiet zone around the barcode. |
foreground |
black |
The color of the bars specified as a 3 or 6 digit hex RGB value or HTML color name. |
background |
white |
The color of the background specified as a 3 or 6 digit hex RGB value or HTML color name. |