Barcodes
bkhtmltopdf has a built-in <barcode> custom tag for generating barcodes and QR codes. It inherits from the standard
<img> tag, so it supports style, class, alt, and other attributes, while adding type, value, and options
for dynamic generation.
Attributes
| Attribute | Type | Description |
|---|---|---|
| type | string | Barcode type (e.g., qrcode, code128), see: Types |
| value | string | Barcode content (e.g., text or URL) |
| options | string | Type-specific options, separated by , (e.g., includetext) |
| width | string | Width (e.g., 200px), default is auto |
| height | string | Height (e.g., 200px), default is auto |
| alt | string | Alternative text for accessible PDFs (screen readers) |
tip
<barcode> is converted to an image during rendering, so keep value short to optimize performance.
Example
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hi, bkhtmltopdf!</title>
</head>
<body>
<barcode type="qrcode" value="Hi, bkhtmltopdf." width="200px" height="200px"
alt="This is a QR code whose value is: Hi, bkhtmltopdf."/>
<barcode type="code128" value="123456789" width="200px" height="200px" options="includetext"
alt="This is a Code 128 whose value is: 123456789"/>
</body>
</html>
Preview

Types
| 类型 | 编码 | 选项 | 值 |
|---|---|---|---|
| AusPost 4 State Customer Code | auspost | includetext custinfoenc=character | 5956439111ABA 9 |
| Aztec Code | azteccode | format=full | This is Aztec Code |
| Aztec Runes | aztecrune | 1 | |
| BC412 | bc412 | semi includetext includecheckintext | BC412SEMI |
| COOP 2 of 5 | coop2of5 | includetext includecheck includecheckintext | 01234567 |
| Channel Code | channelcode | height=12 includetext | 3493 |
| Codabar | rationalizedCodabar | includetext includecheck includecheckintext | A0123456789B |
| Codablock F | codablockf | columns=8 | CODABLOCK F 34567890123456789010040digit |
| Code 11 | code11 | includetext includecheck includecheckintext | 0123456789 |
| Code 128 | code128 | includetext | Count01234567! |
| Code 16K | code16k | Abcd-1234567890-wxyZ | |
| Code 25 | code2of5 | includetext includecheck includecheckintext | 01234567 |
| Code 39 | code39 | includetext includecheck includecheckintext | THIS IS CODE 39 |
| Code 39 Extended | code39ext | includetext includecheck includecheckintext | Code39 Ext! |
| Code 49 | code49 | MULTIPLE ROWS IN CODE 49 | |
| Code 93 | code93 | includetext includecheck | THIS IS CODE 93 |
| Code 93 Extended | code93ext | includetext includecheck | Code93 Ext! |
| Code One | codeone | Code One | |
| Compact Aztec Code | azteccodecompact | 1234 | |
| Compact PDF417 | pdf417compact | columns=2 | This is compact PDF417 |
| Custom 1D symbology | raw | height=12 | 331132131313411122131311333213114131131221323 |
| Custom 4 state symbology | daft | FATDAFTDAD | |
| Data Matrix | datamatrix | This is Data Matrix! | |
| Data Matrix Rectangular | datamatrixrectangular | 1234 | |
| Data Matrix Rectangular Extension | datamatrixrectangularextension | version=8x96 | 1234 |
| Datalogic 2 of 5 | datalogic2of5 | includetext includecheck includecheckintext | 01234567 |
| Deutsche Post Identcode | identcode | includetext | 563102430313 |
| Deutsche Post Leitcode | leitcode | includetext | 21348075016401 |
| DotCode | dotcode | inkspread=0.16 | This is DotCode |
| EAN-13 | ean13 | includetext guardwhitespace | 9520123456788 |
| EAN-13 Composite | ean13composite | includetext | 9520123456788|(99)1234-abcd |
| EAN-14 | ean14 | includetext | (01) 0 952 8765 43210 8 |
| EAN-2 (2 digit addon) | ean2 | includetext guardwhitespace | 05 |
| EAN-5 (5 digit addon) | ean5 | includetext guardwhitespace | 90200 |
| EAN-8 | ean8 | includetext guardwhitespace | 95200002 |
| EAN-8 Composite | ean8composite | includetext | 95200002|(21)A12345678 |
| Flattermarken | flattermarken | inkspread=-0.25 showborder borderleft=0 borderright=0 | 11099 |
| GS1 Composite 2D Component | gs1-cc | ccversion=b cccolumns=4 | (01)09521234543213(3103)000123 |
| GS1 Data Matrix | gs1datamatrix | (01)09521234543213(17)120508(10)ABCD1234(410)9501101020917 | |
| GS1 Data Matrix Rectangular | gs1datamatrixrectangular | (01)09521234543213(17)120508(10)ABCD1234(410)9501101020917 | |
| GS1 DataBar Expanded | databarexpanded | (01)09521234543213(3103)000123 | |
| GS1 DataBar Expanded Composite | databarexpandedcomposite | (01)09521234543213(3103)001234|(91)1A2B3C4D5E | |
| GS1 DataBar Expanded Stacked | databarexpandedstacked | segments=4 | (01)09521234543213(3103)000123 |
| GS1 DataBar Expanded Stacked Composite | databarexpandedstackedcomposite | segments=4 | (01)09521234543213(10)ABCDEF|(21)12345678 |
| GS1 DataBar Limited | databarlimited | (01)09521234543213 | |
| GS1 DataBar Limited Composite | databarlimitedcomposite | (01)09521234543213|(21)abcdefghijklmnopqrst | |
| GS1 DataBar Omnidirectional | databaromni | (01)09521234543213 | |
| GS1 DataBar Omnidirectional Composite | databaromnicomposite | (01)09521234543213|(11)990102 | |
| GS1 DataBar Stacked | databarstacked | (01)09521234543213 | |
| GS1 DataBar Stacked Composite | databarstackedcomposite | (01)09521234543213|(17)010200 | |
| GS1 DataBar Stacked Omnidirectional | databarstackedomni | (01)24012345678905 | |
| GS1 DataBar Stacked Omnidirectional Composite | databarstackedomnicomposite | (01)03612345678904|(11)990102 | |
| GS1 DataBar Truncated | databartruncated | (01)09521234543213 | |
| GS1 DataBar Truncated Composite | databartruncatedcomposite | (01)09521234543213|(11)990102 | |
| GS1 Digital Link Data Matrix | gs1dldatamatrix | includetext | https://id.gs1.org/01/09521234543213/22/ABC%2D123?99=XYZ-987 |
| GS1 Digital Link QR Code | gs1dlqrcode | includetext | HTTPS://ID.GS1.ORG/01/09521234543213/22/ABC%2D123?99=XYZ-987 |
| GS1 DotCode | gs1dotcode | rows=16 | (235)5vBZIF%!<B;?oa%(01)09521234543213(8008)19052001 |
| GS1 North American Coupon | gs1northamericancoupon | includetext segments=8 | (8110)106141416543213500110000310123196000 |
| GS1 QR Code | gs1qrcode | (01)09521234543213(8200)http://www.abc.net(10)ABCD1234(410)9501101020917 | |
| GS1-128 | gs1-128 | includetext | (01)09521234543213(3103)000123 |
| GS1-128 Composite | gs1-128composite | ccversion=c | (00)095287654321012346|(02)09521234543213(37)24(10)1234567ABCDEFG |
| HIBC Aztec Code | hibcazteccode | A999BJC5D6E71 | |
| HIBC Codablock F | hibccodablockf | A999BJC5D6E71 | |
| HIBC Code 128 | hibccode128 | includetext | A999BJC5D6E71 |
| HIBC Code 39 | hibccode39 | includetext | A999BJC5D6E71 |
| HIBC Data Matrix | hibcdatamatrix | A999BJC5D6E71 | |
| HIBC Data Matrix Rectangular | hibcdatamatrixrectangular | A999BJC5D6E71 | |
| HIBC MicroPDF417 | hibcmicropdf417 | A999BJC5D6E71 | |
| HIBC PDF417 | hibcpdf417 | A999BJC5D6E71 | |
| HIBC QR Code | hibcqrcode | A999BJC5D6E71 | |
| Han Xin Code | hanxin | This is Han Xin | |
| IATA 2 of 5 | iata2of5 | includetext includecheck includecheckintext | 01234567 |
| ISBN | isbn | includetext guardwhitespace | 978-1-56581-231-4 90000 |
| ISMN | ismn | includetext guardwhitespace | 979-0-2605-3211-3 |
| ISSN | issn | includetext guardwhitespace | 0311-175X 00 17 |
| ITF-14 | itf14 | includetext | 0 952 1234 54321 3 |
| Industrial 2 of 5 | industrial2of5 | includetext includecheck includecheckintext | 01234567 |
| Interleaved 2 of 5 (ITF) | interleaved2of5 | height=12 includecheck includetext includecheckintext | 2401234567 |
| Italian Pharmacode | code32 | includetext | 01234567 |
| Japan Post 4 State Customer Code | japanpost | includetext includecheckintext | 6540123789-A-K-Z |
| MSI Modified Plessey | msi | includetext includecheck includecheckintext | 0123456789 |
| Marks & Spencer | mands | includetext | 0642118 |
| Matrix 2 of 5 | matrix2of5 | includetext includecheck includecheckintext | 01234567 |
| MaxiCode | maxicode | mode=2 parse | [)>^03001^02996152382802^029840^029001^0291Z00004951^029UPSN^02906X610^029159^0291234567^0291/1^029^029Y^029634 ALPHA DR^029PITTSBURGH^029PA^029^004 |
| Micro QR Code | microqrcode | 1234 | |
| MicroPDF417 | micropdf417 | MicroPDF417 | |
| Miscellaneous symbols | symbol | backgroundcolor=DD000011 | fima |
| PDF417 | pdf417 | columns=2 | This is PDF417 |
| Pharmaceutical Binary Code | pharmacode | showborder | 117480 |
| Pharmazentralnummer (PZN) | pzn | includetext | 123456 |
| Plessey UK | plessey | includetext includecheckintext | 01234ABCD |
| PosiCode | posicode | version=b inkspread=-0.5 parsefnc includetext | ABC123 |
| QR Code | qrcode | eclevel=M | hello |
| Rectangular Micro QR Code | rectangularmicroqrcode | version=R17x139 | 1234 |
| Royal Dutch TPG Post KIX | kix | includetext | 1231FZ13XHS |
| Royal Mail 4 State Customer Code | royalmail | includetext barcolor=FF0000 | LE28HS9Z |
| Royal Mail Mailmark | mailmark | type=29 | JGB 012100123412345678AB19XY1A 0 www.xyz.com |
| SSCC-18 | sscc18 | includetext | (00) 0 9528765 432101234 6 |
| Swiss QR Code | swissqrcode | parse | SPC^CR^LF0200^CR^LF1^CR^LFCH5800791123000889012^CR^LFS^CR^LFRobert Schneider AG^CR^LFRue du Lac^CR^LF1268^CR^LF2501^CR^LFBiel^CR^LFCH^CR^LF^CR^LF^CR^LF^CR^LF^CR^LF^CR^LF^CR^LF^CR^LF199.95^CR^LFCHF^CR^LFK^CR^LFPia-Maria Rutschmann-Schnyder^CR^LFGrosse Marktgasse 28^CR^LF9400 Rorschach^CR^LF^CR^LF^CR^LFCH^CR^LFSCOR^CR^LFRF18539007547034^CR^LF^CR^LFEPD |
| Telepen | telepen | includetext | ABCDEF |
| Telepen Numeric | telepennumeric | includetext | 01234567 |
| Two-track Pharmacode | pharmacode2 | includetext showborder | 117480 |
| UPC-A | upca | includetext | 012345000058 |
| UPC-A Composite | upcacomposite | includetext | 012345000058|(99)1234-abcd |
| UPC-E | upce | includetext | 01234558 |
| UPC-E Composite | upcecomposite | includetext | 01234558|(15)021231 |
| USPS Intelligent Mail | onecode | barcolor=FF0000 | 0123456709498765432101234567891 |
| USPS PLANET | planet | includetext includecheckintext | 01234567890 |
| USPS POSTNET | postnet | includetext includecheckintext | 01234 |
| Ultracode | ultracode | eclevel=EC2 | Awesome colours! |