manual.pmd 198 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067
  1. % Zint Barcode Generator and Zint Barcode Studio User Manual
  2. % Version 2.13.0.9
  3. % December 2024
  4. # 1. Introduction
  5. The Zint project aims to provide a complete cross-platform open source barcode
  6. generating solution. The package currently consists of a Qt-based GUI, a CLI
  7. command line executable and a library with an API to allow developers access to
  8. the capabilities of Zint. It is hoped that Zint provides a solution which is
  9. flexible enough for professional users while at the same time takes care of as
  10. much of the processing as possible to allow easy translation from input data to
  11. barcode image.
  12. The library which forms the main component of the Zint project is currently able
  13. to encode data in over 50 barcode symbologies (types of barcode), for each of
  14. which it is possible to translate that data from either UTF-8 (Unicode) or a raw
  15. 8-bit data stream. The image can be rendered as a
  16. - Windows Bitmap (BMP),
  17. - Enhanced Metafile Format (EMF),
  18. - Encapsulated PostScript (EPS),
  19. - Graphics Interchange Format (GIF),
  20. - ZSoft Paintbrush (PCX) image,
  21. - Portable Network Graphic (PNG) image,
  22. - Tagged Image File Format (TIF), or a
  23. - Scalable Vector Graphic (SVG).
  24. Many options are available for setting the characteristics of the output image
  25. including the size and colour of the image, the amount of error correction used
  26. in the symbol and the orientation of the image.
  27. ## 1.1 Glossary
  28. Some of the words and phrases used in this document are specific to barcoding,
  29. and so a brief explanation is given to help understanding:
  30. symbol
  31. : A symbol is an image which encodes data according to one of the standards.
  32. This encompasses barcodes (linear symbols) as well as any of the other
  33. methods of representing data used in this program.
  34. symbology
  35. : A method of encoding data to create a certain type of symbol.
  36. linear
  37. : A linear or one-dimensional symbol is one which consists of bars and spaces,
  38. and is what most people associate with the term 'barcode'. Examples include
  39. Code 128.
  40. stacked
  41. : A stacked symbol consists of multiple linear symbols placed one above
  42. another and which together hold the message, usually alongside some error
  43. correction data. Examples include PDF417.
  44. matrix
  45. : A matrix symbol is one based on a (usually square) grid of elements called
  46. modules. Examples include Data Matrix, but MaxiCode and DotCode are also
  47. considered matrix symbologies.
  48. composite
  49. : A composite symbology is one which is made up of elements which are both
  50. linear and stacked. Those currently supported are made up of a linear
  51. 'primary' message above which is printed a stacked component based on the
  52. PDF417 symbology. These symbols also have a separator which separates the
  53. linear and the stacked components. The stacked component is most often
  54. referred to as the 2D (two-dimensional) component.
  55. X-dimension
  56. : The X-dimension of a symbol is the size (usually the width) of the smallest
  57. element. For a linear symbology this is the width of the smallest bar. For
  58. matrix symbologies it is the width of the smallest module (usually a
  59. square). Barcode widths and heights are expressed in X-dimensions. Most
  60. linear symbologies can have their height varied whereas most matrix
  61. symbologies have a fixed width-to-height ratio where the height is
  62. determined by the width.
  63. GS1 data
  64. : This is a structured way of representing information which consists of
  65. 'chunks' of data, each of which starts with an Application Identifier (AI).
  66. The AI identifies what type of information is being encoded.
  67. Reader Initialisation (Programming)
  68. : Some symbologies allow a special character to be included which can be
  69. detected by the scanning equipment as signifying that the data is used to
  70. program or change settings in that equipment. This data is usually not
  71. passed on to the software which handles normal input data. This feature
  72. should only be used if you are familiar with the programming codes relevant
  73. to your scanner.
  74. ECI
  75. : The Extended Channel Interpretations (ECI) mechanism allows for
  76. multi-language data to be encoded in symbols which would usually support
  77. only Latin-1 (ISO/IEC 8859-1 plus ASCII) characters. This can be useful, for
  78. example, if you need to encode Cyrillic characters, but should be used with
  79. caution as not all scanners support this method.
  80. Two other concepts that are important are raster and vector.
  81. raster
  82. : A low level bitmap representation of an image. BMP, GIF, PCX, PNG and TIF
  83. are raster file formats.
  84. vector
  85. : A high level command- or data-based representation of an image. EMF, EPS and
  86. SVG are vector file formats. They require renderers to turn them into
  87. bitmaps.
  88. # 2. Installing Zint
  89. ## 2.1 Linux
  90. The easiest way to configure compilation is to take advantage of the CMake
  91. utilities. You will need to install CMake and `libpng-dev` first. For instance
  92. on `apt` systems:
  93. ```bash
  94. sudo apt install git cmake build-essential libpng-dev
  95. ```
  96. If you want to take advantage of Zint Barcode Studio you will also need to have
  97. Qt and its component `"Desktop gcc 64-bit"` installed, as well as `mesa`. For
  98. details see `"README.linux"` in the project root directory.
  99. Once you have fulfilled these requirements unzip the source code tarball or
  100. clone the latest source
  101. ```bash
  102. git clone https://git.code.sf.net/p/zint/code zint
  103. ```
  104. and follow these steps in the top directory:
  105. ```bash
  106. mkdir build
  107. cd build
  108. cmake ..
  109. make
  110. sudo make install
  111. ```
  112. The CLI command line program can be accessed by typing
  113. ```bash
  114. zint [options]
  115. ```
  116. The GUI can be accessed by typing
  117. ```bash
  118. zint-qt
  119. ```
  120. To test that the installation has been successful a shell script is included in
  121. the `"frontend"` sub-directory. To run the test type
  122. ```bash
  123. ./test.sh
  124. ```
  125. This should create numerous files in the sub-directory `"frontend/test_sh_out"`
  126. showing the many modes of operation which are available from Zint.
  127. ## 2.2 BSD
  128. The latest Zint CLI, `libzint` library and GUI can be installed from the `zint`
  129. package on FreeBSD:
  130. ```bash
  131. su
  132. pkg install zint
  133. exit
  134. ```
  135. and on OpenBSD (where the GUI is in a separate `zint-gui` package):
  136. ```bash
  137. su
  138. pkg_add zint zint-gui
  139. exit
  140. ```
  141. To build from source (including for NetBSD) see `"README.bsd"` in the project
  142. root directory.
  143. ## 2.3 Microsoft Windows
  144. For Microsoft Windows, Zint is distributed as a binary executable. Simply
  145. download the ZIP file, then right-click on the ZIP file and `"Extract All"`. A
  146. new folder will be created within which are two binary files:
  147. * `qtZint.exe` - Zint Barcode Studio
  148. * `zint.exe` - Command Line Interface
  149. For fresh releases you will get a warning message from Microsoft Defender
  150. SmartScreen that this is an 'unrecognised app'. This happens because Zint is
  151. a free and open-source software project with no advertising and hence no income,
  152. meaning we are not able to afford the $664 per year to have the application
  153. digitally signed by Microsoft.
  154. To build Zint on Windows from source, see `"win32/README"`.
  155. ## 2.4 Apple macOS
  156. The latest Zint CLI and `libzint` can be installed using Homebrew.[^1] To
  157. install Homebrew input the following line into the macOS terminal
  158. ```bash
  159. /bin/bash -c "$(curl -fsSL \
  160. https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  161. ```
  162. Once Homebrew is installed use the following command to install the CLI and
  163. library
  164. ```bash
  165. brew install zint
  166. ```
  167. To build from source (and install the GUI) see `"README.macos"` in the project
  168. root directory.
  169. [^1]: See the Homebrew website [https://brew.sh](https://brew.sh).
  170. ## 2.5 Zint Tcl Backend
  171. The Tcl backend in the `"backend_tcl"` sub-directory may be built using the
  172. provided TEA (Tcl Extension Architecture) build on Linux, Windows, macOS and
  173. Android. For Windows, an MSVC6 makefile is also available. See [Annex C. Tcl
  174. Backend Binding] for further details.
  175. # 3. Using Zint Barcode Studio
  176. Zint Barcode Studio is the graphical user interface for Zint. If you are
  177. starting from a command line interface you can start the GUI by typing
  178. ```bash
  179. zint-qt
  180. ```
  181. or on Windows
  182. ```bash
  183. qtZint.exe
  184. ```
  185. See the note in section [2.3 Microsoft Windows] about Microsoft Defender
  186. SmartScreen.
  187. Below is a brief guide to Zint Barcode Studio.
  188. ## 3.1 Main Window and Data Tab
  189. ![Zint Barcode Studio on startup - main window with Data
  190. tab](images/gui_main.png){.win}
  191. This is the main window of Zint Barcode Studio. The top of the window shows a
  192. preview of the barcode that the current settings would create. These settings
  193. can be changed using the controls below. The text box in the `"Data to Encode"`
  194. groupbox on this first Data tab allows you to enter the data to be encoded. When
  195. you are happy with your settings you can use the `"Save..."` button to save the
  196. resulting image to a file.
  197. The `"Symbology"` drop-down box gives access to all of the symbologies supported
  198. by Zint shown in alphabetical order. The text box to its right can filter the
  199. drop-down to only show matching symbologies. For instance typing `"mail"` will
  200. only show barcodes in the drop-down whose names contain the word `"mail"`. Each
  201. word entered will match. So typing `"mail post"` will show barcodes whose names
  202. contain `"mail"` or `"post"` (or both).
  203. The ellipsis button `"..."` to the right of the data text box invokes the Data
  204. Dialog - see [3.7 Data Dialog] for details. The delete button
  205. ![delete](images/gui_delete.png){.btn} next to it will clear the data text box
  206. and the ECI (Extended Channel Interpretations) drop-down if set.
  207. To set the barcode as a Programming Initialisation symbol click the
  208. `"Reader Init"` checkbox. The `"1234.."` button to its right invokes the
  209. Sequence Dialog - see [3.8 Sequence Dialog]. The zap button
  210. ![zap](images/gui_zap.png){.btn} will clear all data and reset all settings for
  211. the barcode to defaults.
  212. The `"BMP"` and `"SVG"` buttons at the bottom will copy the image to the
  213. clipboard in BMP format and SVG format respectively. Further copy-to-clipboard
  214. formats are available by clicking the `"Menu"` button, along with
  215. `"CLI Equivalent..."`, `"Save As..."`, `"Factory Reset..."`, `"Help"`,
  216. `"About..."` and `"Quit"` options. Most of the options are also available in a
  217. context menu by right-clicking the preview.
  218. ![Zint Barcode Studio main menu (left) and context menu
  219. (right)](images/gui_menus.png){.win}
  220. ## 3.2 GS1 Composite Groupbox
  221. ![Zint Barcode Studio encoding GS1 Composite
  222. data](images/gui_composite.png){.win}
  223. In the middle of the Data tab is an area for creating composite symbologies
  224. which appears when the currently selected symbology is supported by the GS1
  225. Composite symbology standard. GS1 data can then be entered with square brackets
  226. used to separate Application Identifier (AI) information from data as shown
  227. here. For details, see [6.3 GS1 Composite Symbols (ISO 24723)].
  228. ## 3.3 Additional ECI/Data Segments Groupbox
  229. ![Zint Barcode Studio encoding multiple segments](images/gui_segs.png){.win}
  230. For symbologies that support ECIs (Extended Channel Interpretations) the middle
  231. of the Data tab is an area for entering additional data segments with their own
  232. ECIs. Up to 4 segments (including the main `"Data to Encode"` as segment 0) may
  233. be specified. See [4.16 Multiple Segments] for details.
  234. ## 3.4 Symbology-specific Groupbox
  235. ![Zint Barcode Studio showing Code 2 of 5 Interleaved
  236. settings](images/gui_c25inter.png){.win}
  237. Many symbologies have extra options to change the content, format and appearance
  238. of the symbol generated. For those with few additional options (and no support
  239. for GS1 data or ECIs), the middle of the Data tab is an area for setting those
  240. options.
  241. Here is shown the check digit options for an Interleaved Code 2 of 5 symbol (see
  242. [6.1.2.4 Interleaved Code 2 of 5 (ISO 16390)]).
  243. Symbologies with more than a few options (or support for GS1 data or ECIs) have
  244. a second Symbology-specific tab, shown next.
  245. ## 3.5 Symbology-specific Tab
  246. ![Zint Barcode Studio showing Aztec Code options](images/gui_aztec.png){.win}
  247. A second tab appears for those symbologies with more than a few extra options.
  248. Here is shown the options available for an Aztec Code symbol.
  249. You can adjust its size or error correction level (see [6.6.8 Aztec Code (ISO
  250. 24778)]), select how its data is to be treated (see [4.11 Input Modes]), and set
  251. it as part of a Structured Append sequence of symbols (see [4.17 Structured
  252. Append]).
  253. ## 3.6 Appearance Tab
  254. ![Zint Barcode Studio showing Appearance tab
  255. options](images/gui_appearance.png){.win}
  256. The Appearance tab can be used to adjust the dimensions and other properties of
  257. the symbol.
  258. The `"Height"` value affects the height of symbologies which do not have a fixed
  259. width-to-height ratio, i.e. those other than matrix symbologies. For such
  260. symbologies the `"Automatic Height"` checkbox will be enabled - uncheck this to
  261. manually adjust the height. The `"Compliant Height"` checkbox applies to
  262. symbologies that define a standard height - see [4.4 Adjusting Height].
  263. Boundary bars can be added with the `"Border Type"` drop-down and their size
  264. adjusted with `"Border Width"`, and whitespace can be adjusted both horizontally
  265. (first spinbox) and vertically (second spinbox), and also through the
  266. `"Quiet Zones"` checkbox if standard quiet zones are defined for the symbology.
  267. The size of the saved image can be specified with `"Printing Scale"`, and also
  268. by clicking the ![scaling](images/gui_scaling.png){.btn} icon to invoke the Set
  269. Printing Scale Dialog - see [4.9 Adjusting Image Size (X-dimension)] for further
  270. details.
  271. ![Adjusting the Print Size](images/gui_set_printing_scale.png){.pop}
  272. The foreground and background colours can be set either using the text boxes
  273. which accept `"RRGGBBAA"` hexadecimal values and `"C,M,Y,K"` decimal percentage
  274. values, or by clicking the foreground eye ![eye](images/gui_black_eye.png){.btn}
  275. and background eye ![eye](images/gui_white_eye.png){.btn} buttons which invoke a
  276. colour picker.
  277. ![The colour picker tool](images/gui_colour.png){.pop}
  278. (Note that to change the colours visually, the luminence slider, the long narrow
  279. column on the right, must be adjusted.) The color picker only deals in RGB(A),
  280. and will overwrite any CMYK values with RGB(A) values once `"OK"` is selected.
  281. Back in the Appearance tab, the colours can be reset to black-on-white using the
  282. `"Reset"` button, and exchanged one for the other using the swap
  283. ![swap](images/gui_swap.png){.btn} button next to it.
  284. ## 3.7 Data Dialog
  285. ![Entering longer text input](images/gui_data_dialog.png){.pop}
  286. Clicking on the ellipsis `"..."` button next to the `"Data to Encode"` text box
  287. in the Data tab opens a larger window which can be used to enter longer strings
  288. of text. You can also use this window to load data from a file.
  289. The dialog is also available for additional ECI/Data segments by clicking the
  290. ellipsis button to the right of their data text boxes.
  291. Note that if your data contains line feeds (`LF`) then the data will be split
  292. into separate lines in the dialog box. On saving the data back to the main text
  293. box any separate lines in the data will be escaped as `'\n'` and the
  294. `"Parse Escapes"` checkbox will be set. This only affects line feeds, not
  295. carriage returns (`CR`) or `CR+LF` pairs, and behaves the same on both Windows
  296. and Unix. (For details on escape sequences, see [4.1 Inputting Data].)
  297. ## 3.8 Sequence Dialog
  298. ![Creating a sequence of barcode symbols](images/gui_sequence.png){.pop}
  299. Clicking on the sequence button (labelled `"1234.."`) in the Data tab opens the
  300. Sequence Dialog. This allows you to create multiple barcode images by entering a
  301. sequence of data inputs in the right hand panel. Sequences can also be
  302. automatically generated by entering parameters on the left hand side or by
  303. importing the data from a file. Zint will generate a separate barcode image for
  304. each line of text in the right hand panel. The format field determines the
  305. format of the automatically generated sequence where characters have the
  306. meanings as given below:
  307. | Character | Effect |
  308. |:-------------------|:------------------------|
  309. |`$` | Insert leading zeroes |
  310. |`#` | Insert leading spaces |
  311. |`*` | Insert leading asterisks|
  312. |Any other character | Interpreted literally |
  313. Table: {#tbl:sequence_format_characters tag=": Sequence Format Characters"}
  314. Once you're happy with the Sequence Data, click the `"Export..."` button to
  315. bring up the Export Dialog, discussed next.
  316. ## 3.9 Export Dialog
  317. ![Setting filenames for an exported sequence of barcode
  318. symbols](images/gui_export.png){.pop}
  319. The Export Dialog invoked by pressing the `"Export..."` button in the Sequence
  320. Dialog sets the parameters for exporting the sequence of barcode images. Here
  321. you can set the output directory, the format of the output filenames and what
  322. their image type will be. Note that the symbology, colour and other formatting
  323. information are taken from the main window.
  324. ## 3.10 CLI Equivalent Dialog
  325. ![CLI Equivalent Dialog](images/gui_cli_equivalent.png){.pop}
  326. The CLI Equivalent Dialog can be invoked from the main menu or the context menu
  327. and displays the CLI command that will reproduce the barcode as currently
  328. configured in the GUI. Press the `"Copy"` button to copy the command to the
  329. clipboard, which can then be pasted into the command line.
  330. # 4. Using the Command Line
  331. This section describes how to encode data using the command line frontend (CLI)
  332. program. The examples given are for the Unix platform, but the same options are
  333. available for Windows - just remember to include the executable file extension
  334. if `".EXE"` is not in your `PATHEXT` environment variable, i.e.:
  335. ```bash
  336. zint.exe -d "This Text"
  337. ```
  338. For compatibility with Windows the examples use double quotes to delimit data,
  339. though on Unix single quotes are generally preferable as they stop the shell
  340. from processing any characters such as backslash or dollar. A single quote
  341. itself is dealt with by terminating the single-quoted text, backslashing the
  342. single quote, and then continuing:
  343. ```bash
  344. zint -d 'Text containing a single quote '\'' in the middle'
  345. ```
  346. Some examples use backslash (`\`) to continue commands onto the next line. For
  347. Windows, use caret (`^`) instead.
  348. Certain options that take values have short names as well as long ones, namely
  349. `-b` (`--barcode`), `-d` (`--data`), `-i` (`--input`), `-o` (`--output`) and
  350. `-w` (`--whitesp`). For these a space should be used to separate the short name
  351. from its value, to avoid ambiguity. For long names a space or an equals sign may
  352. be used. For instance:
  353. ```bash
  354. zint -d "This Text"
  355. zint --data="This Text"
  356. zint --data "This Text"
  357. ```
  358. The examples use a space separator for short option names, and an equals sign
  359. for long option names.
  360. ## 4.1 Inputting Data
  361. The data to encode can be entered at the command line using the `-d` or `--data`
  362. option, for example
  363. ```bash
  364. zint -d "This Text"
  365. ```
  366. This will encode the text `"This Text"`. Zint will use the default symbology,
  367. Code 128, and output to the default file `"out.png"` in the current directory.
  368. Alternatively, if `libpng` was not present when Zint was built, the default
  369. output file will be `"out.gif"`.
  370. The data input to the Zint CLI is assumed to be encoded in UTF-8 (Unicode)
  371. format (Zint will correctly handle UTF-8 data on Windows). If you are encoding
  372. characters beyond the 7-bit ASCII set using a scheme other than UTF-8 then you
  373. will need to set the appropriate input options as shown in [4.11 Input Modes]
  374. below.
  375. Non-printing characters can be entered on the command line using backslash (`\`)
  376. as an escape character in combination with the `--esc` switch. Permissible
  377. sequences are shown in the table below.
  378. ---------------------------------------------------------------------------
  379. Escape ASCII Name Interpretation
  380. Sequence Equivalent
  381. ---------- ---------- ----- -------------------------------------------
  382. `\0` 0x00 `NUL` Null character
  383. `\E` 0x04 `EOT` End of Transmission
  384. `\a` 0x07 `BEL` Bell
  385. `\b` 0x08 `BS` Backspace
  386. `\t` 0x09 `HT` Horizontal Tab
  387. `\n` 0x0A `LF` Line Feed
  388. `\v` 0x0B `VT` Vertical Tab
  389. `\f` 0x0C `FF` Form Feed
  390. `\r` 0x0D `CR` Carriage Return
  391. `\e` 0x1B `ESC` Escape
  392. `\G` 0x1D `GS` Group Separator
  393. `\R` 0x1E `RS` Record Separator
  394. `\\` 0x5C `\` Backslash
  395. `\dNNN` NNN Any 8-bit character where NNN is decimal
  396. (000-255)
  397. `\oNNN` 0oNNN Any 8-bit character where NNN is octal
  398. (000-377)
  399. `\xNN` 0xNN Any 8-bit character where NN is hexadecimal
  400. (00-FF)
  401. `\uNNNN` Any 16-bit Unicode BMP[^2] character where
  402. NNNN is hexadecimal (0000-FFFF)
  403. `\UNNNNNN` Any 21-bit Unicode character where NNNNNN
  404. is hexadecimal (000000-10FFFF)
  405. ---------------------------------------------------------------------------
  406. Table: {#tbl:escape_sequences tag=": Escape Sequences"}
  407. [^2]: In Unicode contexts, BMP stands for Basic Multilingual Plane, the plane 0
  408. codeset from U+0000 to U+D7FF and U+E000 to U+FFFF (i.e. excluding surrogates).
  409. Not to be confused with the Windows Bitmap file format BMP!
  410. (Special escape sequences are available for Code 128 only to manually switch
  411. Code Sets and insert special FNC1 characters - see [6.1.10.1 Standard Code 128
  412. (ISO 15417)] for details.)
  413. Input data can be read directly from file using the `-i` or `--input` switch as
  414. shown below. The input file is assumed to be UTF-8 formatted unless an
  415. alternative mode is selected. This option replaces the use of the `-d` switch.
  416. ```bash
  417. zint -i somefile.txt
  418. ```
  419. To read from stdin specify a single hyphen `"-"` as the input file.
  420. Note that except when batch processing (see [4.12 Batch Processing] below), the
  421. file (or stdin) should not end with a newline (`LF` on Unix, `CR+LF` on Windows)
  422. unless you want the newline to be encoded in the symbol.
  423. ## 4.2 Directing Output
  424. Output can be directed to a file other than the default using the `-o` or
  425. `--output` switch. For example:
  426. ```bash
  427. zint -o here.png -d "This Text"
  428. ```
  429. This draws a Code 128 barcode in the file `"here.png"`. If an Encapsulated
  430. PostScript file is needed simply append the filename with `".eps"`, and so on
  431. for the other supported file types:
  432. ```bash
  433. zint -o there.eps -d "This Text"
  434. ```
  435. The currently supported output file formats are shown in the following table.
  436. Extension File format
  437. --------- ------------------------------------
  438. bmp Windows Bitmap
  439. emf Enhanced Metafile Format
  440. eps Encapsulated PostScript
  441. gif Graphics Interchange Format
  442. pcx ZSoft Paintbrush image
  443. png Portable Network Graphic
  444. svg Scalable Vector Graphic
  445. tif Tagged Image File Format
  446. txt Text file (see [4.19 Other Options])
  447. Table: {#tbl:output_file_formats tag=": Output File Formats"}
  448. The filename can contain directories and sub-directories also, which will be
  449. created if they don't already exist:
  450. ```bash
  451. zint -o "dir/subdir/filename.eps" -d "This Text"
  452. ```
  453. Note that on Windows, filenames are assumed to be UTF-8 encoded.
  454. ## 4.3 Selecting Barcode Type
  455. Selecting which type of barcode you wish to produce (i.e. which symbology to
  456. use) can be done at the command line using the `-b` or `--barcode` switch
  457. followed by the appropriate integer value or name in the following table. For
  458. example to create a Data Matrix symbol you could use:
  459. ```bash
  460. zint -b 71 -o datamatrix.png -d "Data to encode"
  461. ```
  462. or
  463. ```bash
  464. zint -b DATAMATRIX -o datamatrix.png -d "Data to encode"
  465. ```
  466. Names are treated case-insensitively by the CLI, and the `BARCODE_` prefix and
  467. any underscores are optional.
  468. -----------------------------------------------------------------------------
  469. Numeric Name[^3] Barcode Name
  470. Value
  471. ------- ------------------------ ------------------------------------------
  472. 1 `BARCODE_CODE11` Code 11
  473. 2`*` `BARCODE_C25STANDARD` Standard Code 2 of 5
  474. 3 `BARCODE_C25INTER` Interleaved 2 of 5
  475. 4 `BARCODE_C25IATA` Code 2 of 5 IATA
  476. 6 `BARCODE_C25LOGIC` Code 2 of 5 Data Logic
  477. 7 `BARCODE_C25IND` Code 2 of 5 Industrial
  478. 8 `BARCODE_CODE39` Code 3 of 9 (Code 39)
  479. 9 `BARCODE_EXCODE39` Extended Code 3 of 9 (Code 39+)
  480. 13 `BARCODE_EANX` EAN (EAN-2, EAN-5, EAN-8 and EAN-13)
  481. 14 `BARCODE_EANX_CHK` EAN + Check Digit
  482. 16`*` `BARCODE_GS1_128` GS1-128 (UCC.EAN-128)
  483. 18 `BARCODE_CODABAR` Codabar
  484. 20 `BARCODE_CODE128` Code 128 (automatic Code Set switching)
  485. 21 `BARCODE_DPLEIT` Deutsche Post Leitcode
  486. 22 `BARCODE_DPIDENT` Deutsche Post Identcode
  487. 23 `BARCODE_CODE16K` Code 16K
  488. 24 `BARCODE_CODE49` Code 49
  489. 25 `BARCODE_CODE93` Code 93
  490. 28 `BARCODE_FLAT` Flattermarken
  491. 29`*` `BARCODE_DBAR_OMN` GS1 DataBar Omnidirectional (including GS1
  492. DataBar Truncated)
  493. 30`*` `BARCODE_DBAR_LTD` GS1 DataBar Limited
  494. 31`*` `BARCODE_DBAR_EXP` GS1 DataBar Expanded
  495. 32 `BARCODE_TELEPEN` Telepen Alpha
  496. 34 `BARCODE_UPCA` UPC-A
  497. 35 `BARCODE_UPCA_CHK` UPC-A + Check Digit
  498. 37 `BARCODE_UPCE` UPC-E
  499. 38 `BARCODE_UPCE_CHK` UPC-E + Check Digit
  500. 40 `BARCODE_POSTNET` POSTNET
  501. 47 `BARCODE_MSI_PLESSEY` MSI Plessey
  502. 49 `BARCODE_FIM` FIM
  503. 50 `BARCODE_LOGMARS` LOGMARS
  504. 51 `BARCODE_PHARMA` Pharmacode One-Track
  505. 52 `BARCODE_PZN` PZN
  506. 53 `BARCODE_PHARMA_TWO` Pharmacode Two-Track
  507. 54 `BARCODE_CEPNET` Brazilian CEPNet
  508. 55 `BARCODE_PDF417` PDF417
  509. 56`*` `BARCODE_PDF417COMP` Compact PDF417 (Truncated PDF417)
  510. 57 `BARCODE_MAXICODE` MaxiCode
  511. 58 `BARCODE_QRCODE` QR Code
  512. 60 `BARCODE_CODE128AB` Code 128 (Suppress Code Set C)
  513. 63 `BARCODE_AUSPOST` Australia Post Standard Customer
  514. 66 `BARCODE_AUSREPLY` Australia Post Reply Paid
  515. 67 `BARCODE_AUSROUTE` Australia Post Routing
  516. 68 `BARCODE_AUSDIRECT` Australia Post Redirection
  517. 69 `BARCODE_ISBNX` ISBN (EAN-13 with verification stage)
  518. 70 `BARCODE_RM4SCC` Royal Mail 4-State Customer Code (RM4SCC)
  519. 71 `BARCODE_DATAMATRIX` Data Matrix (ECC200)
  520. 72 `BARCODE_EAN14` EAN-14
  521. 73 `BARCODE_VIN` Vehicle Identification Number
  522. 74 `BARCODE_CODABLOCKF` Codablock-F
  523. 75 `BARCODE_NVE18` NVE-18 (SSCC-18)
  524. 76 `BARCODE_JAPANPOST` Japanese Postal Code
  525. 77 `BARCODE_KOREAPOST` Korea Post
  526. 79`*` `BARCODE_DBAR_STK` GS1 DataBar Stacked
  527. 80`*` `BARCODE_DBAR_OMNSTK` GS1 DataBar Stacked Omnidirectional
  528. 81`*` `BARCODE_DBAR_EXPSTK` GS1 DataBar Expanded Stacked
  529. 82 `BARCODE_PLANET` PLANET
  530. 84 `BARCODE_MICROPDF417` MicroPDF417
  531. 85`*` `BARCODE_USPS_IMAIL` USPS Intelligent Mail (OneCode)
  532. 86 `BARCODE_PLESSEY` UK Plessey
  533. 87 `BARCODE_TELEPEN_NUM` Telepen Numeric
  534. 89 `BARCODE_ITF14` ITF-14
  535. 90 `BARCODE_KIX` Dutch Post KIX Code
  536. 92 `BARCODE_AZTEC` Aztec Code
  537. 93 `BARCODE_DAFT` DAFT Code
  538. 96 `BARCODE_DPD` DPD Code
  539. 97 `BARCODE_MICROQR` Micro QR Code
  540. 98 `BARCODE_HIBC_128` HIBC Code 128
  541. 99 `BARCODE_HIBC_39` HIBC Code 39
  542. 102 `BARCODE_HIBC_DM` HIBC Data Matrix ECC200
  543. 104 `BARCODE_HIBC_QR` HIBC QR Code
  544. 106 `BARCODE_HIBC_PDF` HIBC PDF417
  545. 108 `BARCODE_HIBC_MICPDF` HIBC MicroPDF417
  546. 110 `BARCODE_HIBC_BLOCKF` HIBC Codablock-F
  547. 112 `BARCODE_HIBC_AZTEC` HIBC Aztec Code
  548. 115 `BARCODE_DOTCODE` DotCode
  549. 116 `BARCODE_HANXIN` Han Xin (Chinese Sensible) Code
  550. 119 `BARCODE_MAILMARK_2D` Royal Mail 2D Mailmark (CMDM) (Data
  551. Matrix)
  552. 121 `BARCODE_MAILMARK_4S` Royal Mail 4-State Mailmark
  553. 128 `BARCODE_AZRUNE` Aztec Runes
  554. 129 `BARCODE_CODE32` Code 32
  555. 130 `BARCODE_EANX_CC` GS1 Composite Symbol with EAN linear
  556. component
  557. 131`*` `BARCODE_GS1_128_CC` GS1 Composite Symbol with GS1-128 linear
  558. component
  559. 132`*` `BARCODE_DBAR_OMN_CC` GS1 Composite Symbol with GS1 DataBar
  560. Omnidirectional linear component
  561. 133`*` `BARCODE_DBAR_LTD_CC` GS1 Composite Symbol with GS1 DataBar
  562. Limited linear component
  563. 134`*` `BARCODE_DBAR_EXP_CC` GS1 Composite Symbol with GS1 DataBar
  564. Expanded linear component
  565. 135 `BARCODE_UPCA_CC` GS1 Composite Symbol with UPC-A linear
  566. component
  567. 136 `BARCODE_UPCE_CC` GS1 Composite Symbol with UPC-E linear
  568. component
  569. 137`*` `BARCODE_DBAR_STK_CC` GS1 Composite Symbol with GS1 DataBar
  570. Stacked component
  571. 138`*` `BARCODE_DBAR_OMNSTK_CC` GS1 Composite Symbol with GS1 DataBar
  572. Stacked Omnidirectional component
  573. 139`*` `BARCODE_DBAR_EXPSTK_CC` GS1 Composite Symbol with GS1 DataBar
  574. Expanded Stacked component
  575. 140 `BARCODE_CHANNEL` Channel Code
  576. 141 `BARCODE_CODEONE` Code One
  577. 142 `BARCODE_GRIDMATRIX` Grid Matrix
  578. 143 `BARCODE_UPNQR` UPNQR (Univerzalnega Plačilnega Naloga QR)
  579. 144 `BARCODE_ULTRA` Ultracode
  580. 145 `BARCODE_RMQR` Rectangular Micro QR Code (rMQR)
  581. 146 `BARCODE_BC412` IBM BC412 (SEMI T1-95)
  582. 147 `BARCODE_DXFILMEDGE` DX Film Edge Barcode
  583. -----------------------------------------------------------------------------
  584. Table: {#tbl:barcode_types tag=": Barcode Types (Symbologies)"}
  585. [^3]: The symbologies marked with an asterisk (`*`) in Table
  586. {@tbl:barcode_types} above used different names in Zint before version 2.9.0.
  587. For example, symbology 29 used the name `BARCODE_RSS14`. These names are now
  588. deprecated but are still recognised by Zint and will continue to be supported in
  589. future versions.
  590. ## 4.4 Adjusting Height
  591. The height of a symbol (except those with a fixed width-to-height ratio) can be
  592. adjusted using the `--height` switch. For example:
  593. ```bash
  594. zint --height=100 -d "This Text"
  595. ```
  596. This specifies a symbol height of 100 times the X-dimension of the symbol.
  597. The default height of most linear barcodes is 50.0X, but this can be changed for
  598. barcodes whose specifications give a standard height by using the switch
  599. `--compliantheight`. For instance
  600. ```bash
  601. zint -b LOGMARS -d "This Text" --compliantheight
  602. ```
  603. will produce a barcode of height 45.455X instead of the normal default of 50.0X.
  604. The flag also causes Zint to return a warning if a non-compliant height is
  605. given:
  606. ```bash
  607. zint -b LOGMARS -d "This Text" --compliantheight --height=6.2
  608. Warning 247: Height not compliant with standards
  609. ```
  610. Another switch is `--heightperrow`, which can be useful for symbologies that
  611. have a variable number of linear rows, namely Codablock-F, Code 16K, Code 49,
  612. GS1 DataBar Expanded Stacked, MicroPDF417 and PDF417, as it changes the
  613. treatment of the height value from overall height to per-row height, allowing
  614. you to specify a consistent height for each linear row without having to know
  615. how many there are. For instance
  616. ```bash
  617. zint -b PDF417 -d "This Text" --height=4 --heightperrow
  618. ```
  619. ![`zint -b PDF417 -d "This Text" --height=4
  620. --heightperrow`](images/pdf417_heightperrow.svg){.lin}
  621. will produce a barcode of height 32X, with each of the 8 rows 4X high.
  622. ## 4.5 Adjusting Whitespace
  623. The amount of horizontal whitespace to the left and right of the generated
  624. barcode can be altered using the `-w` or `--whitesp` switch, in integral
  625. multiples of the X-dimension. For example:
  626. ```bash
  627. zint -w 10 -d "This Text"
  628. ```
  629. This specifies a whitespace width of 10 times the X-dimension of the symbol both
  630. to the left and to the right of the barcode.
  631. The amount of vertical whitespace above and below the barcode can be altered
  632. using the `--vwhitesp` switch, in integral multiples of the X-dimension. For
  633. example for 3 times the X-dimension:
  634. ```bash
  635. zint --vwhitesp=3 -d "This Text"
  636. ```
  637. Note that the whitespace at the bottom appears below the text, if any.
  638. Horizontal and vertical whitespace can of course be used together:
  639. ```bash
  640. zint -b DATAMATRIX --whitesp=1 --vwhitesp=1 -d "This Text"
  641. ```
  642. A `--quietzones` option is also available which adds quiet zones compliant with
  643. the symbology's specification. This is in addition to any whitespace specified
  644. with the `--whitesp` or `--vwhitesp` switches.
  645. Note that Codablock-F, Code 16K, Code 49, ITF-14, EAN-2 to EAN-13, ISBN, UPC-A
  646. and UPC-E have compliant quiet zones added by default. This can be disabled with
  647. the option `--noquietzones`.
  648. ## 4.6 Adding Boundary Bars and Boxes
  649. Zint allows the symbol to be bound with 'boundary bars' (also known as 'bearer
  650. bars') using the option `--bind`. These bars help to prevent misreading of the
  651. symbol by corrupting a scan if the scanning beam strays off the top or bottom of
  652. the symbol. Zint can also put a border right around the symbol and its
  653. horizontal whitespace with the `--box` option.
  654. The width of the boundary bars or box borders, in integral multiples of the
  655. X-dimension, must be specified using the `--border` switch. For example:
  656. ```bash
  657. zint --box --border=10 -w 10 -d "This Text"
  658. ```
  659. ![`zint --border=10 --box -d "This Text" -w 10`](images/code128_box.svg){.lin}
  660. gives a box with a width 10 times the X-dimension of the symbol. Note that when
  661. specifying a box, horizontal whitespace is usually required in order to create a
  662. quiet zone between the barcode and the sides of the box. To add a boundary bar
  663. to the top only use `--bindtop`.
  664. For linear symbols, horizontal boundary bars appear tight against the barcode,
  665. inside any vertical whitespace (or text). For matrix symbols, however, where
  666. they are decorative rather than functional, boundary bars appear outside any
  667. whitespace.
  668. ![`zint -b QRCODE --border=1 --box -d "This Text"
  669. --quietzones`](images/qrcode_box.svg){.i2d}
  670. Codablock-F, Code 16K and Code 49 always have boundary bars, and default to
  671. particular horizontal whitespace values. Special considerations apply to ITF-14
  672. and DPD - see [6.1.2.6 ITF-14] and [6.1.10.7 DPD Code] for those symbologies.
  673. ## 4.7 Using Colour
  674. The default colours of a symbol are a black symbol on a white background. Zint
  675. allows you to change this. The `-r` or `--reverse` switch allows the default
  676. colours to be inverted so that a white symbol is shown on a black background
  677. (known as "reflectance reversal" or "reversed reflectance"). For example the
  678. command
  679. ```bash
  680. zint -r -d "This Text"
  681. ```
  682. gives an inverted Code 128 symbol. This is not practical for most symbologies
  683. but white-on-black is allowed by the Aztec Code, Data Matrix, DotCode, Han Xin
  684. Code, Grid Matrix and QR Code symbology specifications.
  685. For more specific needs the foreground (ink) and background (paper) colours can
  686. be specified using the `--fg` and `--bg` options followed by a number in
  687. `"RRGGBB"` hexadecimal notation (the same system used in HTML) or in `"C,M,Y,K"`
  688. decimal percentages format (the latter normally used with the `--cmyk` option -
  689. see below). For example the command
  690. ```bash
  691. zint --fg=00FF00 -d "This Text"
  692. ```
  693. alters the symbol to a bright green.
  694. ![`zint -d "This Text" --fg=00FF00`](images/code128_green.svg){.lin}
  695. Zint also supports RGBA colour information for those output file formats which
  696. support alpha channels (currently only GIF, PCX, PNG, SVG and TIF, with GIF
  697. supporting either a background or foreground alpha but not both) in a
  698. `"RRGGBBAA"` format. For example:
  699. ```bash
  700. zint --fg=00ff0055 -d "This Text"
  701. ```
  702. ![`zint -d "This Text" --fg=00FF0055`](images/code128_green_alpha.svg){.lin}
  703. will produce a semi-transparent green foreground with a standard (white)
  704. background. Note that transparency is treated differently by raster and vector
  705. (SVG) output formats, as for vector output the background will "shine through" a
  706. transparent foreground. For instance
  707. ```bash
  708. zint --bg=ff0000 --fg=ffffff00 ...
  709. ```
  710. will give different results for PNG and SVG. Experimentation is advised!
  711. In addition the `--nobackground` option will remove the background from all
  712. output formats except BMP.[^4]
  713. The `--cmyk` option is specific to output in Encapsulated PostScript (EPS) and
  714. TIF, and selects the CMYK colour space. Custom colours should then usually be
  715. given in the comma-separated `"C,M,Y,K"` format, where `C`, `M`, `Y` and `K` are
  716. expressed as decimal percentage values from 0 to 100. RGB values may still be
  717. used, in which case they will be converted formulaically to CMYK approximations.
  718. [^4]: The background is omitted for vector outputs EMF, EPS and SVG when
  719. `--nobackground` is given. For raster outputs GIF, PCX, PNG and TIF, the
  720. background's alpha channel is set to zero (fully transparent).
  721. ## 4.8 Rotating the Symbol
  722. The symbol can be rotated through four orientations using the `--rotate` option
  723. followed by the angle of rotation as shown below.
  724. ```
  725. --rotate=0 (default)
  726. --rotate=90
  727. --rotate=180
  728. --rotate=270
  729. ```
  730. ![`zint -d "This Text" --rotate=90`](images/code128_rotate90.svg){.lin}
  731. \clearpage
  732. ## 4.9 Adjusting Image Size (X-dimension)
  733. The size of the image can be altered using the `--scale` option, which sets the
  734. X-dimension. The default scale is 1.0.
  735. The scale is multiplied by 2 (with the exception of MaxiCode) before being
  736. applied to the X-dimension. For MaxiCode, it is multiplied by 10 for raster
  737. output, by 40 for EMF vector output, and by 2 otherwise (non-EMF vector output).
  738. For non-MaxiCode raster output, the default scale of 1 results in an X-dimension
  739. of 2 pixels. For example for non-MaxiCode PNG images a scale of 5 will increase
  740. the X-dimension to 10 pixels. For MaxiCode, see [4.9.3 MaxiCode Raster Scaling]
  741. below.
  742. Scales for non-MaxiCode raster output should be given in increments of 0.5, i.e.
  743. 0.5, 1, 1.5, 2, 2.5, 3, 3.5, etc., to avoid the X-dimension varying across the
  744. symbol due to interpolation. 0.5 increments are also faster to render.
  745. The minimum scale for non-MaxiCode raster output in non-dotty mode is 0.5,
  746. giving a minimum X-dimension of 1 pixel. For MaxiCode, it is 0.2. The minimum
  747. scale for raster output in dotty mode is 1 (see [4.15 Working with Dots]). For
  748. raster output, text will not be printed for scales less than 1.
  749. The minimum scale for vector output is 0.1, giving a minimum X-dimension of 0.2
  750. (or for MaxiCode EMF output, 4). The maximum scale for both raster and vector is
  751. 200.
  752. To summarize the more intricate details:
  753. -----------------------------------------------------------------
  754. MaxiCode? Output Multiplier Min. Scale Min. Scale
  755. (non-dotty) (dotty)
  756. --------- ---------------- ---------- ------------ ----------
  757. No Raster 2 0.5 1
  758. No Vector 2 0.1 0.1
  759. Yes Raster 10 0.2 N/A
  760. Yes Vector (non-EMF) 2 0.1 N/A
  761. Yes EMF 40 0.1 N/A
  762. -----------------------------------------------------------------
  763. Table: {#tbl:scaling_multiplers tag=": Scaling Multipliers and Minima"}
  764. ### 4.9.1 Scaling by X-dimension and Resolution
  765. An alternative way to specify the scale, which takes the above details into
  766. account, is to specify measurable units using the `--scalexdimdp` option, which
  767. has the format
  768. ```
  769. --scalexdimdp=X[,R]
  770. ```
  771. where `X` is the X-dimension (in mm by default) and `R` is the resolution (in
  772. dpmm, dots per mm, by default). `R` is optional, and defaults to 12 dpmm, and
  773. `X` may be zero, in which case it uses a symbology-specific default. The units
  774. may be given in inches for `X` by appending `"in"`, and in dpi (dots per inch)
  775. for `R` by appending `"dpi"`. For example
  776. ```bash
  777. zint -d "1234" --scalexdimdp=0.013in,300dpi
  778. ```
  779. Explicit metric units may also be given by appending `"mm"` and `"dpmm"` as
  780. appropriate, and may be mixed with U.S. units:
  781. ```bash
  782. zint -d "1234" --scalexdimdp=0.33mm,300dpi
  783. ```
  784. ### 4.9.2 Scaling Example
  785. The GS1 General Specifications Section 5.2.6.6 'Symbol dimensions at nominal
  786. size' gives an example of an EAN-13 barcode using the X-dimension of 0.33mm. To
  787. print that example as a PNG at 12 dpmm, the approximate equivalent of 300 dpi
  788. (`dpi = dpmm * 25.4`), specify a scale of 2, since `0.33 * 12 = 3.96` pixels, or
  789. 4 pixels rounding to the nearest pixel:
  790. ```bash
  791. zint -b EANX -d "501234567890" --compliantheight --scale=2
  792. ```
  793. This will result in output of 37.29mm x 25.56mm (WxH) at 12 dpmm. The same
  794. result can be achieved using the `--scalexdimdp` option with
  795. ```bash
  796. zint -b EANX -d "501234567890" --compliantheight --scalexdimdp=0
  797. ```
  798. as 0.33mm is the default X-dimension for EAN, and 12 dpmm the default
  799. resolution.
  800. ### 4.9.3 MaxiCode Raster Scaling
  801. For MaxiCode symbols, which use hexagons, the scale for raster output is
  802. multiplied by 10 before being applied. The 0.5 increment recommended for normal
  803. raster output does not apply.
  804. The minimum scale is 0.2, so the minimum X-dimension is 2 pixels. However scales
  805. below 0.5 are not recommended and may produce symbols that are not within the
  806. following size ranges.
  807. MaxiCode symbols have fixed size ranges of 24.82mm to 27.93mm in width, and
  808. 23.71mm to 26.69mm in height, excluding quiet zones. The default X-dimension is
  809. 0.88mm. For example, to output at the default X-dimension at 600 dpi specify:
  810. ```bash
  811. zint -b MAXICODE -d "MaxiCode (19 chars)" --scalexdimdp=0,600dpi
  812. ```
  813. ## 4.10 Human Readable Text (HRT) Options
  814. For linear barcodes the text present in the output image can be removed by using
  815. the `--notext` option. Note also that for raster output text will not be printed
  816. for scales less than 1 (see [4.9 Adjusting Image Size (X-dimension)]).
  817. Text can be set to bold using the `--bold` option, or a smaller font can be
  818. substituted using the `--small` option. The `--bold` and `--small` options can
  819. be used together if required, but only for vector output.
  820. ![`zint --bold -d "This Text" --small`](images/code128_small_bold.svg){.lin}
  821. The gap between the barcode and the text can be adjusted using the `--textgap`
  822. option, where the gap is given in X-dimensions, and may be negative (minimum
  823. -5.0X, maximum 10.0X). The default gap is 1X. Note that a very small gap may
  824. cause accented texts to overlap with the barcode:
  825. ![`zint -d "Áccent" --textgap=0.1`](images/code128_textgap.svg){.lin}
  826. For SVG output, the font preferred by Zint (monospaced "OCR-B" for EAN/UPC,
  827. "Arimo" - a proportional sans-serif font metrically compatible with "Arial" -
  828. for all others) can be embedded in the file for portability using the
  829. `--embedfont` option:
  830. ![`zint -d "Áccent" --embedfont`](images/code128_embedfont.svg){.lin}
  831. ## 4.11 Input Modes
  832. ### 4.11.1 Unicode, Data, and GS1 Modes
  833. By default all CLI input data is assumed to be encoded in UTF-8 format. Many
  834. barcode symbologies encode data using the Latin-1 (ISO/IEC 8859-1 plus ASCII)
  835. character set, so input is converted from UTF-8 to Latin-1 before being put in
  836. the symbol. In addition QR Code and its variants and Han Xin Code can by default
  837. encode Japanese (Kanji) or Chinese (Hanzi) characters which are also converted
  838. from UTF-8.
  839. There are two exceptions to the Latin-1 default: Grid Matrix, whose default
  840. character set is GB 2312 (Chinese); and UPNQR, whose default character set is
  841. Latin-2 (ISO/IEC 8859-2 plus ASCII).
  842. Symbology Default character sets Alternate if input not Latin-1
  843. ------------- ------------------------ ------------------------------
  844. Aztec Code Latin-1 None
  845. Codablock-F Latin-1 None
  846. Code 128 Latin-1 None
  847. Code 16K Latin-1 None
  848. Code One Latin-1 None
  849. Data Matrix Latin-1 None
  850. DotCode Latin-1 None
  851. Grid Matrix GB 2312 (includes ASCII) N/A
  852. Han Xin Latin-1 GB 18030 (includes ASCII)
  853. MaxiCode Latin-1 None
  854. MicroPDF417 Latin-1 None
  855. Micro QR Code Latin-1 Shift JIS (includes ASCII[^5])
  856. PDF417 Latin-1 None
  857. QR Code Latin-1 Shift JIS (see above)
  858. rMQR Latin-1 Shift JIS (see above)
  859. Ultracode Latin-1 None
  860. UPNQR Latin-2 N/A
  861. All others ASCII N/A
  862. Table: {#tbl:default_character_sets tag=": Default Character Sets"}
  863. [^5]: Shift JIS (JIS X 0201 Roman) re-maps two ASCII characters: backslash (`\`)
  864. to the yen sign (¥), and tilde (`~`) to overline (U+203E).
  865. If Zint encounters characters which can not be encoded using the default
  866. character encoding then it will take advantage of the ECI (Extended Channel
  867. Interpretations) mechanism to encode the data if the symbology supports it - see
  868. [4.11.2 Input Modes and ECI] below.
  869. GS1 data can be encoded in a number of symbologies. Application Identifiers
  870. (AIs) should be enclosed in `[square brackets]` followed by the data to be
  871. encoded (see [6.1.10.3 GS1-128]). To encode GS1 data use the `--gs1` option.
  872. GS1 mode is assumed (and doesn't need to be set) for GS1-128, EAN-14, GS1
  873. DataBar and GS1 Composite symbologies but is also available for Aztec Code, Code
  874. 16K, Code 49, Code One, Data Matrix, DotCode, QR Code and Ultracode.
  875. Health Industry Barcode (HIBC) data may also be encoded in the symbologies Aztec
  876. Code, Codablock-F, Code 128, Code 39, Data Matrix, MicroPDF417, PDF417 and QR
  877. Code. Within this mode, the leading `'+'` and the check character are
  878. automatically added by Zint, conforming to HIBC Labeler Identification Code
  879. (HIBC LIC). For HIBC Provider Applications Standard (HIBC PAS), preface the data
  880. with a slash `'/'`.
  881. The `--binary` option encodes the input data as given. Automatic code page
  882. translation to an ECI page is disabled, and no validation of the data's encoding
  883. takes place. This may be used for raw binary or binary encrypted data. This
  884. switch plays together with the built-in ECI logic and examples may be found
  885. below.
  886. The `--fullmultibyte` option uses the multibyte modes of QR Code, Micro QR Code,
  887. Rectangular Micro QR Code, Han Xin Code and Grid Matrix for non-ASCII data,
  888. maximizing density. This is achieved by using compression designed for
  889. Kanji/Hanzi characters; however some decoders take blocks which are encoded this
  890. way and interpret them as Kanji/Hanzi characters, thus causing data corruption.
  891. Symbols encoded with this option should be checked against decoders before they
  892. are used. The popular open-source ZXing decoder is known to exhibit this
  893. behaviour.
  894. ### 4.11.2 Input Modes and ECI
  895. If your data contains characters that are not in the default character set, you
  896. may encode it using an ECI-aware symbology and an ECI value from Table
  897. {@tbl:eci_codes} below. The ECI information is added to your code symbol as
  898. prefix data. The symbologies that support ECI are
  899. ------------ ------------ ------------
  900. Aztec Code Grid Matrix PDF417
  901. Code One Han Xin Code QR Code
  902. Data Matrix MaxiCode rMQR
  903. DotCode MicroPDF417 Ultracode
  904. ------------ ------------ ------------
  905. Table: {#tbl:eci_aware_symbologies tag=": ECI-Aware Symbologies"}
  906. Be aware that not all barcode readers support ECI mode, so this can sometimes
  907. lead to unreadable barcodes. If you are using characters beyond those supported
  908. by the default character set then you should check that the resulting barcode
  909. can be understood by your target barcode reader.
  910. The ECI value may be specified with the `--eci` switch, followed by the value in
  911. the column `"ECI Code"` in the table below. The input data should be UTF-8
  912. formatted. Zint automatically translates the data into the target encoding.
  913. ECI Code Character Encoding Scheme (ISO/IEC 8859 schemes include ASCII)
  914. -------- --------------------------------------------------------------
  915. 3 ISO/IEC 8859-1 - Latin alphabet No. 1
  916. 4 ISO/IEC 8859-2 - Latin alphabet No. 2
  917. 5 ISO/IEC 8859-3 - Latin alphabet No. 3
  918. 6 ISO/IEC 8859-4 - Latin alphabet No. 4
  919. 7 ISO/IEC 8859-5 - Latin/Cyrillic alphabet
  920. 8 ISO/IEC 8859-6 - Latin/Arabic alphabet
  921. 9 ISO/IEC 8859-7 - Latin/Greek alphabet
  922. 10 ISO/IEC 8859-8 - Latin/Hebrew alphabet
  923. 11 ISO/IEC 8859-9 - Latin alphabet No. 5 (Turkish)
  924. 12 ISO/IEC 8859-10 - Latin alphabet No. 6 (Nordic)
  925. 13 ISO/IEC 8859-11 - Latin/Thai alphabet
  926. 15 ISO/IEC 8859-13 - Latin alphabet No. 7 (Baltic)
  927. 16 ISO/IEC 8859-14 - Latin alphabet No. 8 (Celtic)
  928. 17 ISO/IEC 8859-15 - Latin alphabet No. 9
  929. 18 ISO/IEC 8859-16 - Latin alphabet No. 10
  930. 20 Shift JIS (JIS X 0208 and JIS X 0201)
  931. 21 Windows 1250 - Latin 2 (Central Europe)
  932. 22 Windows 1251 - Cyrillic
  933. 23 Windows 1252 - Latin 1
  934. 24 Windows 1256 - Arabic
  935. 25 UTF-16BE (High order byte first)
  936. 26 UTF-8
  937. 27 ASCII (ISO/IEC 646 IRV)
  938. 28 Big5 (Taiwan) Chinese Character Set
  939. 29 GB 2312 (PRC) Chinese Character Set
  940. 30 Korean Character Set EUC-KR (KS X 1001:2002)
  941. 31 GBK Chinese Character Set
  942. 32 GB 18030 Chinese Character Set
  943. 33 UTF-16LE (Low order byte first)
  944. 34 UTF-32BE (High order bytes first)
  945. 35 UTF-32LE (Low order bytes first)
  946. 170 ISO/IEC 646 Invariant[^6]
  947. 899 8-bit binary data
  948. Table: {#tbl:eci_codes tag=": ECI Codes"}
  949. [^6]: ISO/IEC 646 Invariant is a subset of ASCII with 12 characters undefined:
  950. `#`, `$`, `@`, `[`, `\`, `]`, `^`, `` ` ``, `{`, `|`, `}`, `~`.
  951. An ECI value of 0 does not encode any ECI information in the code symbol (unless
  952. the data contains non-default character set characters). In this case, the
  953. default character set applies (see Table @tbl:default_character_sets above).
  954. If no ECI is specified or a value of 0 is given, and the data does contain
  955. characters other than in the default character set, then Zint will automatically
  956. insert the appropriate single-byte ECI if possible (ECIs 3 to 24, excluding ECI
  957. 20), or failing that ECI 26 (UTF-8). A warning will be generated. This mechanism
  958. is not applied if the `--binary` option is given.
  959. Multiple ECIs can be specified using the `--segN` options - see [4.16 Multiple
  960. Segments].
  961. Note: the `--eci=3` specification should only be used for special purposes.
  962. Using this parameter, the ECI information is explicitly added to the symbol.
  963. Nevertheless, for ECI Code 3, this is not usually required, as this is the
  964. default encoding for most barcodes, which is also active without any ECI
  965. information.
  966. #### 4.11.2.1 Input Modes and ECI Example 1
  967. The Euro sign U+20AC can be encoded in ISO/IEC 8859-15. The Euro sign has the
  968. ISO/IEC 8859-15 codepoint hex `"A4"`. It is encoded in UTF-8 as the hex
  969. sequence: `"E2 82 AC"`. Those 3 bytes are contained in the file
  970. `"utf8euro.txt"`. This command will generate the corresponding code:
  971. ```bash
  972. zint -b 71 --scale=10 --eci=17 -i utf8euro.txt
  973. ```
  974. This is equivalent to the commands (using the `--esc` switch):
  975. ```bash
  976. zint -b 71 --scale=10 --eci=17 --esc -d "\xE2\x82\xAC"
  977. zint -b 71 --scale=10 --eci=17 --esc -d "\u20AC"
  978. ```
  979. and to the command:
  980. ```bash
  981. zint -b 71 --scale=10 --eci=17 -d "€"
  982. ```
  983. ![`zint -b DATAMATRIX --eci=17 -d "€"`](images/datamatrix_euro.svg){.i2d}
  984. #### 4.11.2.2 Input Modes and ECI Example 2
  985. The Chinese character with the Unicode codepoint U+5E38 can be encoded in Big5
  986. encoding. The Big5 representation of this character is the two hex bytes:
  987. `"B1 60"` (contained in the file `"big5char.txt"`). The generation command for
  988. Data Matrix is:
  989. ```bash
  990. zint -b 71 --scale=10 --eci=28 --binary -i big5char.txt
  991. ```
  992. This is equivalent to the command (using the `--esc` switch):
  993. ```bash
  994. zint -b 71 --scale=10 --eci=28 --binary --esc -d "\xB1\x60"
  995. ```
  996. and to the commands (no `--binary` switch so conversion occurs):
  997. ```bash
  998. zint -b 71 --scale=10 --eci=28 --esc -d "\xE5\xB8\xB8"
  999. zint -b 71 --scale=10 --eci=28 --esc -d "\u5E38"
  1000. zint -b 71 --scale=10 --eci=28 -d "常"
  1001. ```
  1002. ![`zint -b DATAMATRIX --eci=28 -d "\u5E38"
  1003. --esc`](images/datamatrix_big5.svg){.i2d}
  1004. #### 4.11.2.3 Input Modes and ECI Example 3
  1005. Some decoders (in particular mobile app ones) for QR Code assume UTF-8 encoding
  1006. by default and do not support ECI. In this case supply UTF-8 data and use the
  1007. `--binary` switch so that the data will be encoded as UTF-8 without conversion:
  1008. ```bash
  1009. zint -b 58 --binary -d "UTF-8 data"
  1010. ```
  1011. ![`zint -b QRCODE --binary -d "\xE2\x82\xAC\xE5\xB8\xB8"
  1012. --esc`](images/qrcode_binary_utf8.svg){.i2d}
  1013. ## 4.12 Batch Processing
  1014. Data can be batch processed by reading from a text file and producing a
  1015. separate barcode image for each line of text in that file. To do this use the
  1016. `--batch` switch together with `-i` to select the input file from which to read
  1017. data. For example
  1018. ```bash
  1019. zint -b EANX --batch -i ean13nos.txt
  1020. ```
  1021. where `"ean13nos.txt"` contains a list of EAN-13 numbers (GTINs), each on its
  1022. own line. Zint will automatically detect the end of a line of text (in either
  1023. Unix or Windows formatted text files) and produce a symbol each time it finds
  1024. this.
  1025. Input files should end with a line feed character - if this is not present then
  1026. Zint will not encode the last line of text, and will warn you that there is a
  1027. problem.
  1028. By default Zint will output numbered filenames starting with `00001.png`,
  1029. `00002.png` etc. To change this behaviour specify the `-o` option using special
  1030. characters in the output filename as shown in the table below:
  1031. Input Character Interpretation
  1032. --------------- ------------------------------------------
  1033. `~` Insert a number or 0
  1034. `#` Insert a number or space
  1035. `@` Insert a number or `*` (or `+` on Windows)
  1036. Any other Insert literally
  1037. Table: {#tbl:batch_filename_formatting tag=": Batch Filename Formatting"}
  1038. For instance
  1039. ```bash
  1040. zint -b EANX --batch -i ean13nos.txt -o file~~~.svg
  1041. ```
  1042. The following table shows some examples to clarify this method:
  1043. Input Filenames Generated
  1044. ----------------- ---------------------------------------------------------
  1045. `-o file~~~.svg` `"file001.svg"`, `"file002.svg"`, `"file003.svg"`
  1046. `-o @@@@bar.png` `"***1.png"`, `"***2.png"`, `"***3.png"` (except Windows)
  1047. `-o @@@@bar.png` `"+++1.png"`, `"+++2.png"`, `"+++3.png"` (on Windows)
  1048. `-o my~~~bar.eps` `"my001bar.eps"`, `"my002bar.eps"`, `"my003bar.eps"`
  1049. `-o t#es~t~.png` `"t es0t1.png"`, `"t es0t2.png"`, `"t es0t3.png"`
  1050. Table: {#tbl:batch_filename_examples tag=": Batch Filename Examples"}
  1051. The special characters can span directories also, which is useful when creating
  1052. a large number of barcodes:
  1053. Input Filenames Generated
  1054. -------------------- ------------------------------------------------------
  1055. `-o dir~/file~~~.svg` `"dir0/file001.svg"`, `"dir0/file002.svg"`, ...
  1056. , `"dir0/file999.svg"`, `"dir1/file000.svg"`, ...
  1057. Table: {#tbl:batch_dir_examples tag=": Batch Directory Examples"}
  1058. For an alternative method of naming output files see the `--mirror` option in
  1059. [4.14 Automatic Filenames] below.
  1060. ## 4.13 Direct Output to stdout
  1061. The finished image files can be output directly to stdout for use as part of a
  1062. pipe by using the `--direct` option. By default `--direct` will output data as a
  1063. PNG image (or GIF image if `libpng` is not present), but this can be altered by
  1064. supplementing the `--direct` option with a `--filetype` option followed by the
  1065. suffix of the file type required. For example:
  1066. ```bash
  1067. zint -b 84 --direct --filetype=pcx -d "Data to encode"
  1068. ```
  1069. This command will output the symbol as a PCX file to stdout. For the supported
  1070. output file formats see Table {@tbl:output_file_formats}.
  1071. * * *
  1072. CAUTION: Outputting binary files to the command shell without catching that data
  1073. in a pipe can have unpredictable results. Use with care!
  1074. * * *
  1075. ## 4.14 Automatic Filenames
  1076. The `--mirror` option instructs Zint to use the data to be encoded as an
  1077. indicator of the filename to be used. This is particularly useful if you are
  1078. processing batch data. For example the input data `"1234567"` will result in a
  1079. file named `"1234567.png"`.
  1080. There are restrictions, however, on what characters can be stored in a filename,
  1081. so the filename may vary from the data if the data includes non-printable
  1082. characters, for example, and may be shortened if the data input is long.
  1083. To set the output file format use the `--filetype` option as detailed above in
  1084. [4.13 Direct Output to stdout]. To output to a specific directory use the `-o`
  1085. option giving the name of the directory (any filename will be ignored, unless
  1086. `--filetype` is not specified, in which case the filename's extension will be
  1087. used).
  1088. ## 4.15 Working with Dots
  1089. Matrix codes can be rendered as a series of dots or circles rather than the
  1090. normal squares by using the `--dotty` option. This option is only available for
  1091. matrix symbologies, and is automatically selected for DotCode. The size of the
  1092. dots can be adjusted using the `--dotsize` option followed by the diameter of
  1093. the dot, where that diameter is in X-dimensions. The minimum dot size is 0.01,
  1094. the maximum is 20. The default size is 0.8.
  1095. The default and minimum scale for raster output in dotty mode is 1.
  1096. ![`zint -b CODEONE -d "123456789012345678" --dotty
  1097. --vers=9`](images/codeone_s_dotty.svg){.dotty}
  1098. ## 4.16 Multiple Segments
  1099. If you need to specify different ECIs for different sections of the input data,
  1100. the `--seg1` to `--seg9` options can be used. Each option is of the form
  1101. `--segN=ECI,data` where `ECI` is the ECI code (see Table {@tbl:eci_codes}) and
  1102. `data` is the data to which this applies. This is in addition to the ECI and
  1103. data specified using the `--eci` and `-d` options which must still be present
  1104. and which in effect constitute segment 0. For instance
  1105. ```bash
  1106. zint -b AZTEC_CODE --eci=9 -d "Κείμενο" --seg1=7,"Текст" --seg2=20,"文章"
  1107. ```
  1108. specifies 3 segments: segment 0 with ECI 9 (Greek), segment 1 with ECI 7
  1109. (Cyrillic), and segment 2 with ECI 20 (Shift JIS). Segments must be consecutive.
  1110. Naturally the symbology must be ECI-aware (see Table
  1111. {@tbl:eci_aware_symbologies}).
  1112. ![`zint -b AZTEC --eci=9 -d "Κείμενο" --seg1=7,"Текст"
  1113. --seg2=20,"文章"`](images/aztec_segs.svg){.i2d}
  1114. ECIs of zero may be given, in which case Zint will automatically determine an
  1115. ECI if necessary, as described in section [4.11.2 Input Modes and ECI].
  1116. Multiple segments are not currently supported for use with GS1 data.
  1117. ## 4.17 Structured Append
  1118. Structured Append is a method of splitting data among several symbols so that
  1119. they form a sequence that can be scanned and re-assembled in the correct order
  1120. on reading, and is available for Aztec Code, Code One, Data Matrix, DotCode,
  1121. Grid Matrix, MaxiCode, MicroPDF417, PDF417, QR Code and Ultracode.
  1122. The `--structapp` option marks a symbol as part of a Structured Append sequence,
  1123. and has the format
  1124. ```
  1125. --structapp=I,C[,ID]
  1126. ```
  1127. ![`zint -b DATAMATRIX -d "2nd of 3"
  1128. --structapp="2,3,5006"`](images/datamatrix_structapp.svg){.i2d}
  1129. where `I` is the index (position) of the symbol in the Structured Append
  1130. sequence, `C` is the count or total number of symbols in the sequence, and `ID`
  1131. is an optional identifier (not available for Code One, DotCode or MaxiCode) that
  1132. is the same for all symbols belonging to the same sequence. The index is 1-based
  1133. and goes from 1 to count. Count must be 2 or more. See the individual
  1134. symbologies for further details.
  1135. ## 4.18 Help Options
  1136. There are three help options which give information about how to use the command
  1137. line. The `-h` or `--help` option will display a list of all of the valid
  1138. options available, and also gives the exact version of the software (the version
  1139. by itself can be displayed with `-v` or `--version`).
  1140. The `-t` or `--types` option gives the table of symbologies along with the
  1141. symbol ID numbers and names.
  1142. The `-e` or `--ecinos` option gives a list of the ECI codes.
  1143. ## 4.19 Other Options
  1144. Zint can output a representation of the symbol data as a set of hexadecimal
  1145. values if asked to output to a text file (`"*.txt"`) or if given the option
  1146. `--filetype=txt`. This can be used for test and diagnostic purposes.
  1147. Additional options are available which are specific to certain symbologies.
  1148. These may, for example, control the amount of error correction data or the size
  1149. of the symbol. These options are discussed in section [6. Types of Symbology] of
  1150. this guide.
  1151. # 5. Using the API
  1152. Zint has been written using the C language and has an API for use with C/C++
  1153. language programs. A Qt interface (see [Annex B. Qt Backend QZint]) is available
  1154. in the `"backend_qt"` sub-directory, and a Tcl interface is available in the
  1155. `"backend_tcl"` sub-directory (see [Annex C. Tcl Backend Binding]).
  1156. The `libzint` API has been designed to be very similar to that used by the GNU
  1157. Barcode package. This allows easy migration from GNU Barcode to Zint. Zint,
  1158. however, uses none of the same function names or option names as GNU Barcode.
  1159. This allows you to use both packages in your application without conflict if you
  1160. wish.
  1161. ## 5.1 Creating and Deleting Symbols
  1162. The symbols manipulated by Zint are held in a `zint_symbol` structure defined in
  1163. `"zint.h"`. These symbol structures are created with the `ZBarcode_Create()`
  1164. function and deleted using the `ZBarcode_Delete()` function. For example the
  1165. following code creates and then deletes a symbol:
  1166. ```c
  1167. #include <zint.h>
  1168. #include <stdio.h>
  1169. int main()
  1170. {
  1171. struct zint_symbol *my_symbol;
  1172. my_symbol = ZBarcode_Create();
  1173. if (my_symbol != NULL) {
  1174. printf("Symbol successfully created!\n");
  1175. ZBarcode_Delete(my_symbol);
  1176. }
  1177. return 0;
  1178. }
  1179. ```
  1180. When compiling this code it will need to be linked with the `libzint` library
  1181. using the `-lzint` option:
  1182. ```bash
  1183. gcc -o simple simple.c -lzint
  1184. ```
  1185. ## 5.2 Encoding and Saving to File
  1186. To encode data in a barcode use the `ZBarcode_Encode()` function. To write the
  1187. symbol to a file use the `ZBarcode_Print()` function. For example the following
  1188. code takes a string from the command line and outputs a Code 128 symbol to a PNG
  1189. file named `"out.png"` (or a GIF file `"out.gif"` if `libpng` is not present) in
  1190. the current working directory:
  1191. ```c
  1192. #include <zint.h>
  1193. int main(int argc, char **argv)
  1194. {
  1195. struct zint_symbol *my_symbol;
  1196. my_symbol = ZBarcode_Create();
  1197. ZBarcode_Encode(my_symbol, argv[1], 0);
  1198. ZBarcode_Print(my_symbol, 0);
  1199. ZBarcode_Delete(my_symbol);
  1200. return 0;
  1201. }
  1202. ```
  1203. This can also be done in one stage using the `ZBarcode_Encode_and_Print()`
  1204. function as shown in the next example:
  1205. ```c
  1206. #include <zint.h>
  1207. int main(int argc, char **argv)
  1208. {
  1209. struct zint_symbol *my_symbol;
  1210. my_symbol = ZBarcode_Create();
  1211. ZBarcode_Encode_and_Print(my_symbol, argv[1], 0, 0);
  1212. ZBarcode_Delete(my_symbol);
  1213. return 0;
  1214. }
  1215. ```
  1216. Note that when using the API, the input data is assumed to be 8-bit binary
  1217. unless the `input_mode` member of the `zint_symbol` structure is set - see [5.11
  1218. Setting the Input Mode] for details.
  1219. ## 5.3 Encoding and Printing Functions in Depth
  1220. The functions for encoding and printing barcodes are defined as:
  1221. ```c
  1222. int ZBarcode_Encode(struct zint_symbol *symbol,
  1223. const unsigned char *source, int length);
  1224. int ZBarcode_Encode_File(struct zint_symbol *symbol,
  1225. const char *filename);
  1226. int ZBarcode_Print(struct zint_symbol *symbol, int rotate_angle);
  1227. int ZBarcode_Encode_and_Print(struct zint_symbol *symbol,
  1228. const unsigned char *source, int length, int rotate_angle);
  1229. int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol,
  1230. const char *filename, int rotate_angle);
  1231. ```
  1232. In these definitions `length` can be used to set the length of the input string.
  1233. This allows the encoding of `NUL` (ASCII 0) characters in those symbologies
  1234. which allow this. A value of 0 (or less than 0) will disable this usage and Zint
  1235. will encode data up to the first `NUL` character in the input string, which must
  1236. be present.
  1237. The `rotate_angle` value can be used to rotate the image when outputting. Valid
  1238. values are 0, 90, 180 and 270.
  1239. The `ZBarcode_Encode_File()` and `ZBarcode_Encode_File_and_Print()` functions
  1240. can be used to encode data read directly from a text file where the filename is
  1241. given in the `NUL`-terminated `filename` string. The special filename `"-"`
  1242. (single hyphen) can be used to read from stdin. Note that on Windows, filenames
  1243. are assumed to be UTF-8 encoded.
  1244. If printing more than one barcode, the `zint_symbol` structure may be re-used by
  1245. calling the `ZBarcode_Clear()` function after each barcode to free any output
  1246. buffers allocated. The `zint_symbol` input members must be reset. To fully
  1247. restore `zint_symbol` to its default state, call `ZBarcode_Reset()` instead.
  1248. ## 5.4 Buffering Symbols in Memory (raster)
  1249. In addition to saving barcode images to file Zint allows you to access a
  1250. representation of the resulting bitmap image in memory. The following functions
  1251. allow you to do this:
  1252. ```c
  1253. int ZBarcode_Buffer(struct zint_symbol *symbol, int rotate_angle);
  1254. int ZBarcode_Encode_and_Buffer(struct zint_symbol *symbol,
  1255. const unsigned char *source, int length, int rotate_angle);
  1256. int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol,
  1257. const char *filename, int rotate_angle);
  1258. ```
  1259. The arguments here are the same as above, and rotation and colour options can be
  1260. used with the buffer functions in the same way as when saving to a file. The
  1261. difference is that instead of saving the image to a file it is placed in a byte
  1262. (`unsigned char`) array pointed to by the `bitmap` member, with `bitmap_width`
  1263. set to the number of columns and `bitmap_height` set to the number of rows.
  1264. The RGB channels are split into 3 consecutive red, green, blue bytes per pixel,
  1265. and there are `bitmap_width` pixels per row and `bitmap_height` rows, so the
  1266. total size of the `bitmap` array is `3 * bitmap_width * bitmap_height`.
  1267. If the background and/or foreground are RGBA then the byte array `alphamap` will
  1268. also be set, with a single alpha value for each pixel. Its total size will be
  1269. `bitmap_width * bitmap_height`.
  1270. The pixel data can be extracted from the array (or arrays) by the method shown
  1271. in the example below, where `render_rgb()` and `render_rgba()` are assumed to be
  1272. functions for drawing an RGB and RGBA pixel on the screen implemented by the
  1273. client application:
  1274. ```c
  1275. int row, col, i = 0, j = 0;
  1276. int red, blue, green, alpha;
  1277. for (row = 0; row < my_symbol->bitmap_height; row++) {
  1278. for (col = 0; col < my_symbol->bitmap_width; col++) {
  1279. red = (int) my_symbol->bitmap[i];
  1280. green = (int) my_symbol->bitmap[i + 1];
  1281. blue = (int) my_symbol->bitmap[i + 2];
  1282. if (my_symbol->alphamap) {
  1283. alpha = (int) my_symbol->alphamap[j];
  1284. render_rgba(row, col, red, green, blue, alpha);
  1285. j++;
  1286. } else {
  1287. render_rgb(row, col, red, green, blue);
  1288. }
  1289. i += 3;
  1290. }
  1291. }
  1292. ```
  1293. Where speed is important, the buffer can be returned instead in a more compact
  1294. intermediate form using the output option `OUT_BUFFER_INTERMEDIATE`. Here each
  1295. byte is an ASCII value: `'1'` for foreground colour and `'0'` for background
  1296. colour, except for Ultracode, which also uses colour codes: `'W'` for white,
  1297. `'C'` for cyan, `'B'` for blue, `'M'` for magenta, `'R'` for red, `'Y'` for
  1298. yellow, `'G'` for green, and `'K'` for black. Alpha values are not reported
  1299. (`alphamap` will always be `NULL`). The loop for accessing the data is then:
  1300. ```c
  1301. int row, col, i = 0;
  1302. for (row = 0; row < my_symbol->bitmap_height; row++) {
  1303. for (col = 0; col < my_symbol->bitmap_width; col++) {
  1304. render_pixel(row, col, my_symbol->bitmap[i]);
  1305. i++;
  1306. }
  1307. }
  1308. ```
  1309. ## 5.5 Buffering Symbols in Memory (vector)
  1310. Symbols can also be saved to memory in a vector representation as well as a
  1311. bitmap one. The following functions, exactly analogous to the ones above, allow
  1312. you to do this:
  1313. ```c
  1314. int ZBarcode_Buffer_Vector(struct zint_symbol *symbol, int rotate_angle);
  1315. int ZBarcode_Encode_and_Buffer_Vector(struct zint_symbol *symbol,
  1316. const unsigned char *source, int length, int rotate_angle);
  1317. int ZBarcode_Encode_File_and_Buffer_Vector(struct zint_symbol *symbol,
  1318. const char *filename, int rotate_angle);
  1319. ```
  1320. Here the `vector` member is set to point to a `zint_vector` header structure
  1321. which contains pointers to lists of structures representing the various elements
  1322. of the barcode: rectangles, hexagons, strings and circles. To draw the barcode,
  1323. each of the element types is iterated in turn, and using the information stored
  1324. is drawn by a rendering system. For instance, to draw a barcode using a
  1325. rendering system with `prepare_canvas()`, `draw_rect()`, `draw_hexagon()`,
  1326. `draw_string()`, and `draw_circle()` routines available:
  1327. ```c
  1328. struct zint_vector_rect *rect;
  1329. struct zint_vector_hexagon *hex;
  1330. struct zint_vector_string *string;
  1331. struct zint_vector_circle *circle;
  1332. prepare_canvas(my_symbol->vector->width, my_symbol->vector->height,
  1333. my_symbol->scale, my_symbol->fgcolour, my_symbol->bgcolour,
  1334. rotate_angle);
  1335. for (rect = my_symbol->vector->rectangles; rect; rect = rect->next) {
  1336. draw_rect(rect->x, rect->y, rect->width, rect->height,
  1337. rect->colour);
  1338. }
  1339. for (hex = my_symbol->vector->hexagons; hex; hex = hex->next) {
  1340. draw_hexagon(hex->x, hex->y, hex->diameter, hex->rotation);
  1341. }
  1342. for (string = my_symbol->vector->strings; string; string = string->next) {
  1343. draw_string(string->x, string->y, string->fsize,
  1344. string->rotation, string->halign,
  1345. string->text, string->length);
  1346. }
  1347. for (circle = my_symbol->vector->circles; circle; circle = circle->next) {
  1348. draw_circle(circle->x, circle->y, circle->diameter, circle->width);
  1349. }
  1350. ```
  1351. ## 5.6 Buffering Symbols in Memory (memfile)
  1352. Symbols can also be stored as "in-memory" file buffers by giving the
  1353. `BARCODE_MEMORY_FILE` option to the `output_options` member, which saves the
  1354. print output to member `memfile` instead of to the output file `outfile`. The
  1355. length of the buffer is given in `memfile_size`. For instance:
  1356. ```c
  1357. #include <zint.h>
  1358. #include <stdio.h>
  1359. #include <string.h>
  1360. int main(int argc, char **argv)
  1361. {
  1362. struct zint_symbol *my_symbol;
  1363. my_symbol = ZBarcode_Create();
  1364. my_symbol->output_options |= BARCODE_MEMORY_FILE;
  1365. /* Only the extension is used, to determine output format */
  1366. strcpy(my_symbol->outfile, "mem.svg");
  1367. ZBarcode_Encode_and_Print(my_symbol, argv[1], 0, 0);
  1368. /* `my_symbol->memfile` now contains the SVG output */
  1369. fwrite(my_symbol->memfile, 1, my_symbol->memfile_size, stdout);
  1370. ZBarcode_Delete(my_symbol);
  1371. return 0;
  1372. }
  1373. ```
  1374. will print the SVG output to `stdout` (the file "mem.svg" is not created). This
  1375. is particularly useful for the textual formats EPS and SVG,[^7] allowing the
  1376. output to be manipulated and processed by the client.
  1377. [^7]: BARCODE_MEMORY_FILE textual formats EPS and SVG will have Unix newlines
  1378. (LF) on both Windows and Unix, i.e. not CR+LF on Windows.
  1379. ## 5.7 Setting Options
  1380. So far our application is not very useful unless we plan to only make Code 128
  1381. symbols and we don't mind that they only save to `"out.png"` (or to memory, as
  1382. above). As with the CLI program, of course, these options can be altered. The
  1383. way this is done is by altering the contents of the `zint_symbol` structure
  1384. between the creation and encoding stages. The `zint_symbol` structure consists
  1385. of the following members:
  1386. -----------------------------------------------------------------------------
  1387. Member Name Type Meaning Default Value
  1388. ------------------- ---------- ------------------------- -----------------
  1389. `symbology` integer Symbol to use - see [5.9 `BARCODE_CODE128`
  1390. Specifying a Symbology].
  1391. `height` float Symbol height in Symbol dependent
  1392. X-dimensions, excluding
  1393. fixed width-to-height
  1394. symbols.[^8]
  1395. `scale` float Scale factor for 1.0
  1396. adjusting size of image
  1397. (sets X-dimension).
  1398. `whitespace_width` integer Horizontal whitespace 0
  1399. width in X-dimensions.
  1400. `whitespace_height` integer Vertical whitespace 0
  1401. height in X-dimensions.
  1402. `border_width` integer Border width in 0
  1403. X-dimensions.
  1404. `output_options` integer Set various output 0 (none)
  1405. parameters - see [5.10
  1406. Adjusting Output
  1407. Options].
  1408. `fgcolour` character Foreground (ink) `"000000"`
  1409. string colour as RGB/RGBA
  1410. hexadecimal string or
  1411. `"C,M,Y,K"` decimal
  1412. percentages string, with
  1413. a terminating `NUL`.
  1414. `bgcolour` character Background (paper) `"ffffff"`
  1415. string colour as RGB/RGBA
  1416. hexadecimal string or
  1417. `"C,M,Y,K"` decimal
  1418. percentages string, with
  1419. a terminating `NUL`.
  1420. `fgcolor` pointer Points to fgcolour
  1421. allowing alternate
  1422. spelling.
  1423. `bgcolor` pointer Points to bgcolour
  1424. allowing alternate
  1425. spelling.
  1426. `outfile` character Contains the name of the `"out.png"`
  1427. string file to output a
  1428. resulting barcode symbol
  1429. to. Must end in `.png`,
  1430. `.gif`, `.bmp`, `.emf`,
  1431. `.eps`, `.pcx`, `.svg`,
  1432. `.tif` or `.txt` followed
  1433. by a terminating
  1434. `NUL`.[^9]
  1435. `primary` character Primary message data for `""` (empty)
  1436. string more complex symbols,
  1437. with a terminating `NUL`.
  1438. `option_1` integer Symbol specific options. -1
  1439. `option_2` integer Symbol specific options. 0
  1440. `option_3` integer Symbol specific options. 0
  1441. `show_hrt` integer Set to 0 to hide Human 1
  1442. Readable Text (HRT).
  1443. `input_mode` integer Set encoding of input `DATA_MODE`
  1444. data - see [5.11 Setting
  1445. the Input Mode].
  1446. `eci` integer Extended Channel 0 (none)
  1447. Interpretation code.
  1448. `dpmm` float Resolution of output in 0 (none)
  1449. dots per mm (BMP, EMF,
  1450. PCX, PNG and TIF only).
  1451. `dot_size` float Diameter of dots used in 0.8
  1452. dotty mode (in
  1453. X-dimensions).
  1454. `text_gap` float Gap between barcode and 1.0
  1455. text (HRT) in
  1456. X-dimensions.
  1457. `guard_descent` float Height of guard bar 5.0
  1458. descent (EAN/UPC only) in
  1459. X-dimensions.
  1460. `structapp` Structured Mark a symbol as part of count 0
  1461. Append a sequence of symbols. (disabled)
  1462. structure
  1463. `debug` integer Debugging flags. 0
  1464. `warn_level` integer Affects error/warning `WARN_DEFAULT`
  1465. value returned by Zint
  1466. API - see [5.8 Handling
  1467. Errors].
  1468. `text` unsigned Human Readable Text, `""` (empty)
  1469. character which usually consists of (output only)
  1470. string input data plus one more
  1471. check digit. Uses UTF-8
  1472. formatting, with a
  1473. terminating `NUL`.
  1474. `rows` integer Number of rows used by (output only)
  1475. the symbol.
  1476. `width` integer Width of the generated (output only)
  1477. symbol.
  1478. `encoded_data` array of Representation of the (output only)
  1479. unsigned encoded data.
  1480. character
  1481. arrays
  1482. `row_height` array of Heights of each row. (output only)
  1483. floats
  1484. `errtxt` character Error message in the (output only)
  1485. string event that an error
  1486. occurred, with a
  1487. terminating `NUL` - see
  1488. [5.8 Handling Errors].
  1489. `bitmap` pointer to Pointer to stored bitmap (output only)
  1490. unsigned image - see [5.4
  1491. character Buffering Symbols in
  1492. array Memory (raster)].
  1493. `bitmap_width` integer Width of stored bitmap (output only)
  1494. image (in pixels) - see
  1495. `bitmap` member.
  1496. `bitmap_height` integer Height of stored bitmap (output only)
  1497. image (in pixels) - see
  1498. `bitmap` member.
  1499. `alphamap` pointer to Pointer to array (output only)
  1500. unsigned representing alpha
  1501. character channel of stored bitmap
  1502. array image (or `NULL` if no
  1503. alpha channel used) - see
  1504. `bitmap` member.
  1505. `vector` pointer to Pointer to vector header (output only)
  1506. vector containing pointers to
  1507. structure vector elements - see
  1508. [5.5 Buffering Symbols
  1509. in Memory (vector)].
  1510. `memfile` pointer to Pointer to in-memory (output only)
  1511. unsigned file buffer if
  1512. character `BARCODE_MEMORY_FILE`
  1513. array set in `output_options`
  1514. - see [5.6 Buffering
  1515. Symbols in Memory
  1516. (memfile)].
  1517. `memfile_size` integer Length of in-memory file (output only)
  1518. buffer.
  1519. -----------------------------------------------------------------------------
  1520. Table: API Structure `zint_symbol` {#tbl:api_structure_zint_symbol tag="$ $"}
  1521. [^8]: The `height` value is ignored for Aztec (including HIBC and Aztec Rune),
  1522. Code One, Data Matrix (including HIBC), DotCode, Grid Matrix, Han Xin, MaxiCode,
  1523. QR Code (including HIBC, Micro QR, rMQR and UPNQR), and Ultracode - all of which
  1524. have a fixed width-to-height ratio (or, in the case of Code One, a fixed
  1525. height).
  1526. [^9]: For Windows, `outfile` is assumed to be UTF-8 encoded.
  1527. To alter these values use the syntax shown in the example below. This code has
  1528. the same result as the previous example except the output is now taller and
  1529. plotted in green.
  1530. ```c
  1531. #include <zint.h>
  1532. #include <string.h>
  1533. int main(int argc, char **argv)
  1534. {
  1535. struct zint_symbol *my_symbol;
  1536. my_symbol = ZBarcode_Create();
  1537. strcpy(my_symbol->fgcolour, "00ff00");
  1538. my_symbol->height = 400.0f;
  1539. ZBarcode_Encode_and_Print(my_symbol, argv[1], 0, 0);
  1540. ZBarcode_Delete(my_symbol);
  1541. return 0;
  1542. }
  1543. ```
  1544. Note that background removal for all outputs except BMP can be achieved by
  1545. setting the background alpha to `"00"` where the values for R, G and B will be
  1546. ignored:
  1547. ```c
  1548. strcpy(my_symbol->bgcolour, "55555500");
  1549. ```
  1550. This is what the CLI option `--nobackground` does - see [4.7 Using Colour].
  1551. ## 5.8 Handling Errors
  1552. If errors occur during encoding a non-zero integer value is passed back to the
  1553. calling application. In addition the `errtxt` member is set to a message
  1554. detailing the nature of the error. The errors generated by Zint are:
  1555. ------------------------------------------------------------------------------
  1556. Return Value Meaning
  1557. ----------------------------- -----------------------------------------------
  1558. `ZINT_WARN_HRT_TRUNCATED` The Human Readable Text returned in `text` was
  1559. truncated (maximum 255 bytes).
  1560. `ZINT_WARN_INVALID_OPTION` One of the values in `zint_struct` was set
  1561. incorrectly but Zint has made a guess at what
  1562. it should have been and generated a barcode
  1563. accordingly.
  1564. `ZINT_WARN_USES_ECI` Zint has automatically inserted an ECI
  1565. character. The symbol may not be readable with
  1566. some readers.
  1567. `ZINT_WARN_NONCOMPLIANT` The symbol was created but is not compliant
  1568. with certain standards set in its specification
  1569. (e.g. height, GS1 AI data lengths).
  1570. `ZINT_ERROR` Marks the divide between warnings and errors.
  1571. For return values greater than or equal to this
  1572. no symbol (or only an incomplete symbol) is
  1573. generated.
  1574. `ZINT_ERROR_TOO_LONG` The input data is too long or too short for the
  1575. selected symbology. No symbol has been
  1576. generated.
  1577. `ZINT_ERROR_INVALID_DATA` The data to be encoded includes characters
  1578. which are not permitted by the selected
  1579. symbology (e.g. alphabetic characters in an EAN
  1580. symbol). No symbol has been generated.
  1581. `ZINT_ERROR_INVALID_CHECK` Data with an incorrect check digit has been
  1582. entered. No symbol has been generated.
  1583. `ZINT_ERROR_INVALID_OPTION` One of the values in `zint_struct` was set
  1584. incorrectly and Zint was unable (or unwilling)
  1585. to guess what it should have been. No symbol
  1586. has been generated.
  1587. `ZINT_ERROR_ENCODING_PROBLEM` A problem has occurred during encoding of the
  1588. data. This should never happen. Please contact
  1589. the developer if you encounter this error.
  1590. `ZINT_ERROR_FILE_ACCESS` Zint was unable to open the requested output
  1591. file. This is usually a file permissions
  1592. problem.
  1593. `ZINT_ERROR_MEMORY` Zint ran out of memory. This should only be a
  1594. problem with legacy systems.
  1595. `ZINT_ERROR_FILE_WRITE` Zint failed to write all contents to the
  1596. requested output file. This should only occur
  1597. if the output device becomes full.
  1598. `ZINT_ERROR_USES_ECI` Returned if `warn_level` set to `WARN_FAIL_ALL`
  1599. and `ZINT_WARN_USES_ECI` occurs.
  1600. `ZINT_ERROR_NONCOMPLIANT` Returned if `warn_level` set to `WARN_FAIL_ALL`
  1601. and `ZINT_WARN_NONCOMPLIANT` occurs.
  1602. `ZINT_ERROR_HRT_TRUNCATED` Returned if `warn_level` set to `WARN_FAIL_ALL`
  1603. and `ZINT_WARN_HRT_TRUNCATED` occurs.
  1604. ------------------------------------------------------------------------------
  1605. Table: {#tbl:api_warnings_errors tag=": API Warning and Error Return Values"}
  1606. To catch errors use an integer variable as shown in the code below:
  1607. ```c
  1608. #include <zint.h>
  1609. #include <stdio.h>
  1610. #include <string.h>
  1611. int main(int argc, char **argv)
  1612. {
  1613. struct zint_symbol *my_symbol;
  1614. int error;
  1615. my_symbol = ZBarcode_Create();
  1616. /* Set invalid foreground colour */
  1617. strcpy(my_symbol->fgcolour, "nonsense");
  1618. error = ZBarcode_Encode_and_Print(my_symbol, argv[1], 0, 0);
  1619. if (error != 0) {
  1620. /* Some warning or error occurred */
  1621. printf("%s\n", my_symbol->errtxt);
  1622. if (error >= ZINT_ERROR) {
  1623. /* Stop now */
  1624. ZBarcode_Delete(my_symbol);
  1625. return 1;
  1626. }
  1627. }
  1628. /* Otherwise carry on with the rest of the application */
  1629. ZBarcode_Delete(my_symbol);
  1630. return 0;
  1631. }
  1632. ```
  1633. This code will exit with the appropriate message:
  1634. ```
  1635. Error 881: Malformed foreground RGB colour 'nonsense' (hexadecimal only)
  1636. ```
  1637. To treat all warnings as errors, set `symbol->warn_level` to `WARN_FAIL_ALL`.
  1638. ## 5.9 Specifying a Symbology
  1639. Symbologies can be specified by number or by name as shown in the Table
  1640. {@tbl:barcode_types}. For example
  1641. ```c
  1642. symbol->symbology = BARCODE_LOGMARS;
  1643. ```
  1644. means the same as
  1645. ```c
  1646. symbol->symbology = 50;
  1647. ```
  1648. ## 5.10 Adjusting Output Options
  1649. The `output_options` member can be used to adjust various aspects of the output
  1650. file. To select more than one option from the table below simply `OR` them
  1651. together when adjusting this value:
  1652. ```c
  1653. my_symbol->output_options |= BARCODE_BIND | READER_INIT;
  1654. ```
  1655. ------------------------------------------------------------------------------
  1656. Value Effect
  1657. ------------------------- ---------------------------------------------------
  1658. 0 No options selected.
  1659. `BARCODE_BIND_TOP` Boundary bar above the symbol only.[^10]
  1660. `BARCODE_BIND` Boundary bars above and below the symbol and
  1661. between rows if stacking multiple symbols.[^11]
  1662. `BARCODE_BOX` Add a box surrounding the symbol and whitespace.
  1663. `BARCODE_STDOUT` Output the file to stdout.
  1664. `READER_INIT` Create as a Reader Initialisation (Programming)
  1665. symbol.
  1666. `SMALL_TEXT` Use a smaller font for the Human Readable Text.
  1667. `BOLD_TEXT` Embolden the Human Readable Text.
  1668. `CMYK_COLOUR` Select the CMYK colour space option for
  1669. Encapsulated PostScript and TIF files.
  1670. `BARCODE_DOTTY_MODE` Plot a matrix symbol using dots rather than
  1671. squares.
  1672. `GS1_GS_SEPARATOR` Use GS (Group Separator) instead of FNC1 as GS1
  1673. separator (Data Matrix only).
  1674. `OUT_BUFFER_INTERMEDIATE` Return the bitmap buffer as ASCII values instead of
  1675. separate colour channels - see [5.4 Buffering
  1676. Symbols in Memory (raster)].
  1677. `BARCODE_QUIET_ZONES` Add compliant quiet zones (additional to any
  1678. specified whitespace).[^12]
  1679. `BARCODE_NO_QUIET_ZONES` Disable quiet zones, notably those with defaults.
  1680. `COMPLIANT_HEIGHT` Warn if height specified not compliant, or use
  1681. standard height (if any) as default.
  1682. `EANUPC_GUARD_WHITESPACE` Add quiet zone indicators ("<" and/or ">") to HRT
  1683. whitespace (EAN/UPC).
  1684. `EMBED_VECTOR_FONT` Embed font in vector output - currently available
  1685. for SVG output only.
  1686. `BARCODE_MEMORY_FILE` Write output to in-memory buffer `symbol->memfile`
  1687. instead of to `outfile` file.
  1688. ------------------------------------------------------------------------------
  1689. Table: API `output_options` Values {#tbl:api_output_options tag="$ $"}
  1690. [^10]: The `BARCODE_BIND_TOP` flag is set by default for DPD - see [6.1.10.7 DPD
  1691. Code].
  1692. [^11]: The `BARCODE_BIND` flag is always set for Codablock-F, Code 16K and Code
  1693. 49. Special considerations apply to ITF-14 - see [6.1.2.6 ITF-14].
  1694. [^12]: Codablock-F, Code 16K, Code 49, EAN-2 to EAN-13, ISBN, ITF-14, UPC-A and
  1695. UPC-E have compliant quiet zones added by default.
  1696. ## 5.11 Setting the Input Mode
  1697. The way in which the input data is encoded can be set using the `input_mode`
  1698. member. Valid values are shown in the table below.
  1699. ------------------------------------------------------------------------------
  1700. Value Effect
  1701. ------------------ ----------------------------------------------------------
  1702. `DATA_MODE` Uses full 8-bit range interpreted as binary data.
  1703. `UNICODE_MODE` Uses UTF-8 input.
  1704. `GS1_MODE` Encodes GS1 data using FNC1 characters.
  1705. _The above are exclusive, the following optional and
  1706. OR-ed._
  1707. `ESCAPE_MODE` Process input data for escape sequences.
  1708. `GS1PARENS_MODE` Parentheses (round brackets) used in GS1 data instead of
  1709. square brackets to delimit Application Identifiers
  1710. (parentheses must not otherwise occur in the data).
  1711. `GS1NOCHECK_MODE` Do not check GS1 data for validity, i.e. suppress checks
  1712. for valid AIs and data lengths. Invalid characters (e.g.
  1713. control characters, extended ASCII characters) are still
  1714. checked for.
  1715. `HEIGHTPERROW_MODE` Interpret the `height` member as per-row rather than as
  1716. overall height.
  1717. `FAST_MODE` Use faster if less optimal encodation or other shortcuts
  1718. if available (affects `DATAMATRIX`, `MICROPDF417`,
  1719. `PDF417`, `QRCODE` and `UPNQR` only).
  1720. `EXTRA_ESCAPE_MODE` Process special symbology-specific escape sequences
  1721. (`CODE128` only).
  1722. ------------------------------------------------------------------------------
  1723. Table: API `input_mode` Values {#tbl:api_input_mode tag="$ $"}
  1724. The default mode is `DATA_MODE`. (Note that this differs from the default for
  1725. the CLI and GUI, which is `UNICODE_MODE`.)
  1726. `DATA_MODE`, `UNICODE_MODE` and `GS1_MODE` are mutually exclusive, whereas
  1727. `ESCAPE_MODE`, `GS1PARENS_MODE`, `GS1NOCHECK_MODE`, `HEIGHTPERROW_MODE`,
  1728. `FAST_MODE` and `EXTRA_ESCAPE_MODE` are optional. So, for example, you can set
  1729. ```c
  1730. my_symbol->input_mode = UNICODE_MODE | ESCAPE_MODE;
  1731. ```
  1732. or
  1733. ```c
  1734. my_symbol->input_mode = GS1_MODE | GS1PARENS_MODE | GS1NOCHECK_MODE;
  1735. ```
  1736. whereas
  1737. ```c
  1738. my_symbol->input_mode = DATA_MODE | GS1_MODE;
  1739. ```
  1740. is not valid.
  1741. Permissible escape sequences (`ESCAPE_MODE`) are listed in Table
  1742. {@tbl:escape_sequences}, and the special Code 128-only `EXTRA_ESCAPE_MODE`
  1743. escape sequences are given in [6.1.10.1 Standard Code 128 (ISO 15417)]. An
  1744. example of `GS1PARENS_MODE` usage is given in section [6.1.10.3 GS1-128].
  1745. `GS1NOCHECK_MODE` is for use with legacy systems that have data that does not
  1746. conform to the current GS1 standard. Printable ASCII input is still checked for,
  1747. as is the validity of GS1 data specified without AIs (e.g. linear data for GS1
  1748. DataBar Omnidirectional/Limited/etc.). Also checked is GS1 DataBar Expanded and
  1749. GS1 Composite input that is not in the GS1 encodable character set 82 (see GS1
  1750. General Specifications Figure 7.11.1 'GS1 AI encodable character set 82'),
  1751. otherwise encodation would fail.
  1752. For `HEIGHTPERROW_MODE`, see `--heightperrow` in section [4.4 Adjusting Height].
  1753. The `height` member should be set to the desired per-row value on input (it will
  1754. be set to the overall height on output).
  1755. `FAST_MODE` causes a less optimal encodation scheme to be used for Data Matrix,
  1756. MicroPDF417 and PDF417. For QR Code and UPNQR, it affects Zint's automatic mask
  1757. selection - see [6.6.3 QR Code (ISO 18004)] for details.
  1758. ## 5.12 Multiple Segments
  1759. For input data requiring multiple ECIs, the following functions may be used:
  1760. ```c
  1761. int ZBarcode_Encode_Segs(struct zint_symbol *symbol,
  1762. const struct zint_seg segs[], const int seg_count);
  1763. int ZBarcode_Encode_Segs_and_Print(struct zint_symbol *symbol,
  1764. const struct zint_seg segs[], const int seg_count, int rotate_angle);
  1765. int ZBarcode_Encode_Segs_and_Buffer(struct zint_symbol *symbol,
  1766. const struct zint_seg segs[], const int seg_count, int rotate_angle);
  1767. int ZBarcode_Encode_Segs_and_Buffer_Vector(struct zint_symbol *symbol,
  1768. const struct zint_seg segs[], const int seg_count, int rotate_angle);
  1769. ```
  1770. These are direct analogues of the previously mentioned `ZBarcode_Encode()`,
  1771. `ZBarcode_Encode_and_Print()`, `ZBarcode_Encode_and_Buffer()` and
  1772. `ZBarcode_Encode_and_Buffer_Vector()` respectively, where instead of a pair
  1773. consisting of `"source, length"`, a pair consisting of `"segs, seg_count"` is
  1774. given, with `segs` being an array of `struct zint_seg` segments and `seg_count`
  1775. being the number of elements it contains. The zint_seg structure is of the form:
  1776. ```c
  1777. struct zint_seg {
  1778. unsigned char *source; /* Data to encode */
  1779. int length; /* Length of `source`. If 0, `source` must be
  1780. NUL-terminated */
  1781. int eci; /* Extended Channel Interpretation */
  1782. };
  1783. ```
  1784. The symbology must support ECIs (see Table {@tbl:eci_aware_symbologies}). For
  1785. example:
  1786. ```c
  1787. #include <zint.h>
  1788. int main(int argc, char **argv)
  1789. {
  1790. struct zint_seg segs[] = {
  1791. { "Κείμενο", 0, 9 },
  1792. { "Текст", 0, 7 },
  1793. { "文章", 0, 20 }
  1794. };
  1795. struct zint_symbol *my_symbol;
  1796. my_symbol = ZBarcode_Create();
  1797. my_symbol->symbology = BARCODE_AZTEC;
  1798. my_symbol->input_mode = UNICODE_MODE;
  1799. ZBarcode_Encode_Segs(my_symbol, segs, 3);
  1800. ZBarcode_Print(my_symbol, 0);
  1801. ZBarcode_Delete(my_symbol);
  1802. return 0;
  1803. }
  1804. ```
  1805. A maximum of 256 segments may be specified. Use of multiple segments with GS1
  1806. data is not currently supported.
  1807. ## 5.13 Scaling Helpers
  1808. To help with scaling the output, the following three function are available:
  1809. ```c
  1810. float ZBarcode_Default_Xdim(int symbol_id);
  1811. float ZBarcode_Scale_From_XdimDp(int symbol_id, float x_dim_mm, float dpmm,
  1812. const char *filetype) {
  1813. float ZBarcode_XdimDP_From_Scale(int symbol_id, float scale,
  1814. float x_dim_mm_or_dpmm, const char *filetype);
  1815. ```
  1816. The first `ZBarcode_Default_Xdim()` returns the default X-dimension suggested by
  1817. Zint for symbology `symbol_id`.
  1818. The second `ZBarcode_Scale_From_XdimDp()` returns the scale to use to output to
  1819. a file of type `filetype` with X-dimension `x_dim_mm` at `dpmm` dots per mm. The
  1820. given X-dimension must be non-zero and less than or equal to 10mm, however
  1821. `dpmm` may be zero and defaults to 12 dpmm, and `filetype` may be NULL or empty
  1822. in which case a GIF filetype is assumed. For raster output (BMP/GIF/PCX/PNG/TIF)
  1823. the scale is rounded to half-integer increments.
  1824. For example:
  1825. ```c
  1826. /* Royal Mail 4-State Customer Code */
  1827. my_symbol->symbology = BARCODE_RM4SCC;
  1828. my_symbol->dpmm = 600.0f / 25.4f; /* 600 dpi */
  1829. my_symbol->scale = ZBarcode_Scale_From_XdimDp(
  1830. my_symbol->symbology,
  1831. ZBarcode_Default_Xdim(my_symbol->symbology),
  1832. my_symbol->dpmm, "PNG"); /* Returns 7.5 */
  1833. ```
  1834. The third function `ZBarcode_XdimDP_From_Scale()` is the "reverse" of
  1835. `ZBarcode_Scale_From_XdimDp()`, returning the X-dimension (in mm) or the dot
  1836. density (in dpmm) given a scale `scale`. Both `scale` and `x_dim_mm_or_dpmm`
  1837. must be non-zero. The returned value is bound to the maximum value of dpmm
  1838. (1000), so must be further bound to 10 on return if the X-dimension is sought.
  1839. Note that the X-dimension to use is application dependent, and varies not only
  1840. due to the symbology, resolution and filetype but also due to the type of
  1841. scanner used, the intended scanning distance, and what media ("substrates") the
  1842. barcode appears on.
  1843. ## 5.14 Verifying Symbology Availability
  1844. An additional function available in the API is:
  1845. ```c
  1846. int ZBarcode_ValidID(int symbol_id);
  1847. ```
  1848. which allows you to check whether a given symbology is available, returning a
  1849. non-zero value if so. For example:
  1850. ```c
  1851. if (ZBarcode_ValidID(BARCODE_PDF417) != 0) {
  1852. printf("PDF417 available\n");
  1853. } else {
  1854. printf("PDF417 not available\n");
  1855. }
  1856. ```
  1857. Another function that may be useful is:
  1858. ```c
  1859. int ZBarcode_BarcodeName(int symbol_id, char name[32]);
  1860. ```
  1861. which copies the name of a symbology into the supplied `name` buffer, which
  1862. should be 32 characters in length. The name is `NUL`-terminated, and zero is
  1863. returned on success. For instance:
  1864. ```c
  1865. char name[32];
  1866. if (ZBarcode_BarcodeName(BARCODE_PDF417, name) == 0) {
  1867. printf("%s\n", name);
  1868. }
  1869. ```
  1870. will print `BARCODE_PDF417`.
  1871. ## 5.15 Checking Symbology Capabilities
  1872. It can be useful for frontend programs to know the capabilities of a symbology.
  1873. This can be determined using another additional function:
  1874. ```c
  1875. unsigned int ZBarcode_Cap(int symbol_id, unsigned int cap_flag);
  1876. ```
  1877. by `OR`-ing the flags below in the `cap_flag` argument and checking the return
  1878. to see which are set.
  1879. ------------------------------------------------------------------------------
  1880. Value Meaning
  1881. ------------------------- --------------------------------------------------
  1882. `ZINT_CAP_HRT` Can the symbology print Human Readable Text?
  1883. `ZINT_CAP_STACKABLE` Is the symbology stackable?
  1884. `ZINT_CAP_EANUPC`[^13] Is the symbology EAN/UPC?
  1885. `ZINT_CAP_COMPOSITE` Does the symbology support composite data? (see
  1886. [6.3 GS1 Composite Symbols (ISO 24723)] below)
  1887. `ZINT_CAP_ECI` Does the symbology support Extended Channel
  1888. Interpretations?
  1889. `ZINT_CAP_GS1` Does the symbology support GS1 data?
  1890. `ZINT_CAP_DOTTY` Can the symbology be outputted as dots?
  1891. `ZINT_CAP_QUIET_ZONES` Does the symbology have default quiet zones?
  1892. `ZINT_CAP_FIXED_RATIO` Does the symbology have a fixed width-to-height
  1893. (aspect) ratio?
  1894. `ZINT_CAP_READER_INIT` Does the symbology support Reader Initialisation?
  1895. `ZINT_CAP_FULL_MULTIBYTE` Is the `ZINT_FULL_MULTIBYTE` option applicable?
  1896. `ZINT_CAP_MASK` Is mask selection applicable?
  1897. `ZINT_CAP_STRUCTAPP` Does the symbology support Structured Append?
  1898. `ZINT_CAP_COMPLIANT_HEIGHT` Does the symbology have a compliant height
  1899. defined?
  1900. ------------------------------------------------------------------------------
  1901. Table: {#tbl:api_cap tag=": API Capability Flags"}
  1902. [^13]: `ZINT_CAP_EANUPC` was previously named `ZINT_CAP_EXTENDABLE`, which is
  1903. still recognised.
  1904. For example:
  1905. ```c
  1906. unsigned int cap;
  1907. cap = ZBarcode_Cap(BARCODE_PDF417, ZINT_CAP_HRT | ZINT_CAP_ECI);
  1908. if (cap & ZINT_CAP_HRT) {
  1909. printf("PDF417 supports HRT\n");
  1910. } else {
  1911. printf("PDF417 does not support HRT\n");
  1912. }
  1913. if (cap & ZINT_CAP_ECI) {
  1914. printf("PDF417 supports ECI\n");
  1915. } else {
  1916. printf("PDF417 does not support ECI\n");
  1917. }
  1918. ```
  1919. ## 5.16 Zint Version
  1920. Whether the Zint library linked to was built with PNG support may be determined
  1921. with:
  1922. ```c
  1923. int ZBarcode_NoPng();
  1924. ```
  1925. which returns 1 if no PNG support is available, else zero.
  1926. Lastly, the version of the Zint library linked to is returned by:
  1927. ```c
  1928. int ZBarcode_Version();
  1929. ```
  1930. The version parts are separated by hundreds. For instance, version `"2.9.1"` is
  1931. returned as `"20901"`.
  1932. # 6. Types of Symbology
  1933. ## 6.1 One-Dimensional Symbols
  1934. One-dimensional or linear symbols are what most people associate with the term
  1935. barcode. They consist of a number of bars and a number of spaces of differing
  1936. widths.
  1937. ### 6.1.1 Code 11
  1938. ![`zint -b CODE11 -d "9212320967"`](images/code11.svg){.lin}
  1939. Developed by Intermec in 1977, Code 11 is similar to Code 2 of 5 Matrix and is
  1940. primarily used in telecommunications. The symbol can encode data consisting of
  1941. the digits 0-9 and the dash character (`-`) up to a maximum of 140 characters.
  1942. Two modulo-11 check digits are added by default. To add just one check digit,
  1943. set `--vers=1` (API `option_2 = 1`). To add no check digits, set `--vers=2`
  1944. (API `option_2 = 2`).
  1945. ### 6.1.2 Code 2 of 5
  1946. Code 2 of 5 is a family of one-dimensional symbols, 8 of which are supported by
  1947. Zint. Note that the names given to these standards alters from one source to
  1948. another so you should take care to ensure that you have the right barcode type
  1949. before using these standards.
  1950. #### 6.1.2.1 Standard Code 2 of 5
  1951. ![`zint -b C25STANDARD -d "9212320967"`](images/c25standard.svg){.lin}
  1952. Also known as Code 2 of 5 Matrix, this is a self-checking code used in
  1953. industrial applications and photo development. Standard Code 2 of 5 will encode
  1954. numeric input (digits 0-9) up to a maximum of 112 digits. No check digit is
  1955. added by default. To add a check digit, set `--vers=1` (API `option_2 = 1`). To
  1956. add a check digit but not show it in the Human Readable Text, set `--vers=2`
  1957. (API `option_2 = 2`).
  1958. #### 6.1.2.2 IATA Code 2 of 5
  1959. ![`zint -b C25IATA -d "9212320967"`](images/c25iata.svg){.lin}
  1960. Used for baggage handling in the air-transport industry by the International Air
  1961. Transport Agency, this self-checking code will encode numeric input (digits 0-9)
  1962. up to a maximum of 80 digits. No check digit is added by default, but can be set
  1963. the same as for [6.1.2.1 Standard Code 2 of 5].
  1964. #### 6.1.2.3 Industrial Code 2 of 5
  1965. ![`zint -b C25IND -d "9212320967"`](images/c25ind.svg){.lin}
  1966. Industrial Code 2 of 5 can encode numeric input (digits 0-9) up to a maximum of
  1967. 79 digits. No check digit is added by default, but can be set the same as for
  1968. [6.1.2.1 Standard Code 2 of 5].
  1969. #### 6.1.2.4 Interleaved Code 2 of 5 (ISO 16390)
  1970. ![`zint -b C25INTER --compliantheight -d
  1971. "9212320967"`](images/c25inter.svg){.lin}
  1972. This self-checking symbology encodes pairs of numbers, and so can only encode an
  1973. even number of digits (0-9). If an odd number of digits is entered a leading
  1974. zero is added by Zint. A maximum of 62 pairs (124 digits) can be encoded. No
  1975. check digit is added by default, but can be set the same as for [6.1.2.1
  1976. Standard Code 2 of 5].
  1977. #### 6.1.2.5 Code 2 of 5 Data Logic
  1978. ![`zint -b C25LOGIC -d "9212320967"`](images/c25logic.svg){.lin}
  1979. Data Logic does not include a check digit by default and can encode numeric
  1980. input (digits 0-9) up to a maximum of 113 digits. Check digit options are the
  1981. same as for [6.1.2.1 Standard Code 2 of 5].
  1982. #### 6.1.2.6 ITF-14
  1983. ![`zint -b ITF14 --compliantheight -d "9212320967145"`](images/itf14.svg){.lin}
  1984. ITF-14, also known as UPC Shipping Container Symbol or Case Code, is based on
  1985. Interleaved Code 2 of 5 and requires a 13-digit numeric input (digits 0-9). One
  1986. modulo-10 check digit is added by Zint.
  1987. If no border option is specified Zint defaults to adding a bounding box with a
  1988. border width of 5. This behaviour can be overridden by using the `--bind` option
  1989. (API `output_options |= BARCODE_BIND`). Similarly the border width can be
  1990. overridden using `--border` (API `border_width`). If a symbol with no border is
  1991. required this can be achieved by explicitly setting the border type to box (or
  1992. bind or bindtop) and leaving the border width 0.
  1993. ![`zint -b ITF14 --box --compliantheight -d
  1994. "9212320967145"`](images/itf14_border0.svg){.lin}
  1995. #### 6.1.2.7 Deutsche Post Leitcode
  1996. ![`zint -b DPLEIT -d "9212320967145"`](images/dpleit.svg){.lin}
  1997. Leitcode is based on Interleaved Code 2 of 5 and is used by Deutsche Post for
  1998. routing purposes. Leitcode requires a 13-digit numerical input to which Zint
  1999. adds a check digit.
  2000. #### 6.1.2.8 Deutsche Post Identcode
  2001. ![`zint -b DPIDENT -d "91232096712"`](images/dpident.svg){.lin}
  2002. Identcode is based on Interleaved Code 2 of 5 and is used by Deutsche Post for
  2003. identification purposes. Identcode requires an 11-digit numerical input to which
  2004. Zint adds a check digit.
  2005. \clearpage
  2006. ### 6.1.3 UPC (Universal Product Code) (ISO 15420)
  2007. #### 6.1.3.1 UPC Version A
  2008. ![`zint -b UPCA --compliantheight -d "72527270270"`](images/upca.svg){.upcean}
  2009. UPC-A is used in the United States for retail applications. The symbol requires
  2010. an 11-digit article number. The check digit is calculated by Zint. In addition
  2011. EAN-2 and EAN-5 add-on symbols can be added using the + character. For example,
  2012. to draw a UPC-A symbol with the data 72527270270 with an EAN-5 add-on showing
  2013. the data 12345 use the command:
  2014. ```bash
  2015. zint -b UPCA -d "72527270270+12345"
  2016. ```
  2017. or using the API encode a data string with the + character included:
  2018. ```c
  2019. my_symbol->symbology = BARCODE_UPCA;
  2020. error = ZBarcode_Encode_and_Print(my_symbol, "72527270270+12345", 0, 0);
  2021. ```
  2022. ![`zint -b UPCA --compliantheight -d
  2023. "72527270270+12345"`](images/upca_5.svg){.upcean}
  2024. If your input data already includes the check digit symbology `BARCODE_UPCA_CHK`
  2025. (35) can be used which takes a 12-digit input and validates the check digit
  2026. before encoding.
  2027. A quiet zone indicator can be added to the HRT by setting `--guardwhitespace`
  2028. (API `output_options |= EANUPC_GUARD_WHITESPACE`). For UPC, this is only
  2029. relevant when there is add-on:
  2030. ```bash
  2031. zint -b UPCA -d "72527270270+12345" --guardwhitespace
  2032. ```
  2033. or using the API:
  2034. ```c
  2035. my_symbol->symbology = BARCODE_UPCA;
  2036. my_symbol->output_options |= EANUPC_GUARD_WHITESPACE;
  2037. error = ZBarcode_Encode_and_Print(my_symbol, "72527270270+12345", 0, 0);
  2038. ```
  2039. ![`zint -b UPCA --compliantheight -d "72527270270+12345"
  2040. --guardwhitespace`](images/upca_5_gws.svg){.upcean}
  2041. You can adjust the gap between the main symbol and an add-on in integral
  2042. multiples of the X-dimension by setting `--addongap` (API `option_2`) to a value
  2043. between 9 (default) and 12. The height in X-dimensions that the guard bars
  2044. descend below the main bars can be adjusted by setting `--guarddescent` (API
  2045. `guard_descent`) to a value between 0.0 and 20.0 (default 5.0).
  2046. #### 6.1.3.2 UPC Version E
  2047. ![`zint -b UPCE --compliantheight -d "1123456"`](images/upce.svg){.upcean}
  2048. UPC-E is a zero-compressed version of UPC-A developed for smaller packages. The
  2049. code requires a 6-digit article number (digits 0-9). The check digit is
  2050. calculated by Zint. EAN-2 and EAN-5 add-on symbols can be added using the +
  2051. character as with UPC-A. In addition Zint also supports Number System 1 encoding
  2052. by entering a 7-digit article number starting with the digit 1. For example:
  2053. ```bash
  2054. zint -b UPCE -d "1123456"
  2055. ```
  2056. or
  2057. ```c
  2058. my_symbol->symbology = BARCODE_UPCE;
  2059. error = ZBarcode_Encode_and_Print(my_symbol, "1123456", 0, 0);
  2060. ```
  2061. If your input data already includes the check digit symbology `BARCODE_UPCE_CHK`
  2062. (38) can be used which takes a 7 or 8-digit input and validates the check digit
  2063. before encoding.
  2064. As with UPC-A, a quiet zone indicator can be added when there is an add-on by
  2065. setting `--guardwhitespace` (API `output_options |= EANUPC_GUARD_WHITESPACE`):
  2066. ```bash
  2067. zint -b UPCE -d "1123456+12" --guardwhitespace
  2068. ```
  2069. ![`zint -b UPCE --compliantheight -d "1123456+12"
  2070. --guardwhitespace`](images/upce_2_gws.svg){.upcean}
  2071. You can adjust the gap between the main symbol and an add-on in integral
  2072. multiples of the X-dimension by setting `--addongap` (API `option_2`) to a value
  2073. between 7 (default) and 12. The height in X-dimensions that the guard bars
  2074. descend below the main bars can be adjusted by setting `--guarddescent` (API
  2075. `guard_descent`) to a value between 0.0 and 20.0 (default 5.0).
  2076. ### 6.1.4 EAN (European Article Number) (ISO 15420)
  2077. #### 6.1.4.1 EAN-2, EAN-5, EAN-8 and EAN-13
  2078. ![`zint -b EANX --compliantheight -d
  2079. "4512345678906"`](images/eanx13.svg){.upcean}
  2080. The EAN system is used in retail across Europe and includes standards for EAN-2,
  2081. EAN-5, EAN-8 and EAN-13 which encode 2, 5, 7 or 12-digit numbers respectively.
  2082. Zint will decide which symbology to use depending on the length of the input
  2083. data. In addition EAN-2 and EAN-5 add-on symbols can be added to EAN-8 and
  2084. EAN-13 symbols using the + character as with UPC symbols. For example:
  2085. ```bash
  2086. zint -b EANX -d "54321"
  2087. ```
  2088. ![`zint -b EANX --compliantheight -d "54321"`](images/eanx5.svg){.upcean}
  2089. will encode a stand-alone EAN-5, whereas
  2090. ```bash
  2091. zint -b EANX -d "7432365+54321"
  2092. ```
  2093. will encode an EAN-8 symbol with an EAN-5 add-on. As before these results can be
  2094. achieved using the API:
  2095. ```c
  2096. my_symbol->symbology = BARCODE_EANX;
  2097. error = ZBarcode_Encode_and_Print(my_symbol, "54321", 0, 0);
  2098. error = ZBarcode_Encode_and_Print(my_symbol, "7432365+54321", 0, 0);
  2099. ```
  2100. ![`zint -b EANX --compliantheight -d
  2101. "7432365+54321"`](images/eanx8_5.svg){.upcean}
  2102. All of the EAN symbols include check digits which are added by Zint.
  2103. If you are encoding an EAN-8 or EAN-13 symbol and your data already includes the
  2104. check digit then you can use symbology `BARCODE_EANX_CHK` (14) which takes an 8
  2105. or 13-digit input and validates the check digit before encoding.
  2106. Options to add quiet zone indicators and to adjust the add-on gap and the guard
  2107. bar descent height are the same as for [6.1.3.2 UPC Version E]. For instance:
  2108. ```bash
  2109. zint -b EANX_CHK -d "74323654" --guardwhitespace
  2110. ```
  2111. ![`zint -b EANX_CHK --compliantheight -d "74323654"`
  2112. --guardwhitespace](images/eanx8_gws.svg){.upcean}
  2113. #### 6.1.4.2 SBN, ISBN and ISBN-13
  2114. ![`zint -b ISBNX --compliantheight -d
  2115. "9789295055124"`](images/isbnx.svg){.upcean}
  2116. EAN-13 symbols (also known as Bookland EAN-13) can also be produced from 9-digit
  2117. SBN, 10-digit ISBN or 13-digit ISBN-13 data. The relevant check digit needs to
  2118. be present in the input data and will be verified before the symbol is
  2119. generated.
  2120. As with EAN-13, a quiet zone indicator can be added using `--guardwhitespace`:
  2121. ![`zint -b ISBNX --compliantheight -d "9789295055124"
  2122. --guardwhitespace`](images/isbnx_gws.svg){.upcean}
  2123. EAN-2 and EAN-5 add-on symbols can be added using the + character, and there are
  2124. options to adjust the add-on gap and the guard bar descent height - see [6.1.3.2
  2125. UPC Version E].
  2126. ### 6.1.5 Plessey
  2127. #### 6.1.5.1 UK Plessey
  2128. ![`zint -b PLESSEY -d "C64"`](images/plessey.svg){.lin}
  2129. Also known as Plessey Code, this symbology was developed by the Plessey Company
  2130. Ltd. in the UK. The symbol can encode data consisting of digits (0-9) or letters
  2131. A-F up to a maximum of 67 characters and includes a hidden CRC check digit.
  2132. #### 6.1.5.2 MSI Plessey
  2133. ![`zint -b MSI_PLESSEY -d "6502" --vers=2`](images/msi_plessey.svg){.lin}
  2134. Based on Plessey and developed by MSI Data Corporation, MSI Plessey can encode
  2135. numeric (digits 0-9) input of up to 92 digits. It has a range of check digit
  2136. options that are selectable by setting `--vers` (API `option_2`), shown in the
  2137. table below:
  2138. Value Check Digits
  2139. ----- ---------------------------
  2140. 0 None
  2141. 1 Modulo-10 (Luhn)
  2142. 2 Modulo-10 & Modulo-10
  2143. 3 Modulo-11 (IBM)
  2144. 4 Modulo-11 (IBM) & Modulo-10
  2145. 5 Modulo-11 (NCR)
  2146. 6 Modulo-11 (NCR) & Modulo-10
  2147. Table: {#tbl:msi_plessey_check_digits tag=": MSI Plessey Check Digit Options"}
  2148. To not show the check digit or digits in the Human Readable Text, add 10 to the
  2149. `--vers` value. For example `--vers=12` (API `option_2 = 12`) will add two
  2150. hidden modulo-10 check digits.
  2151. ### 6.1.6 Telepen
  2152. #### 6.1.6.1 Telepen Alpha
  2153. ![`zint -b TELEPEN --compliantheight -d "Z80"`](images/telepen.svg){.lin}
  2154. Telepen Alpha was developed by SB Electronic Systems Limited and can encode
  2155. ASCII text input, up to a maximum of 69 characters. Telepen includes a
  2156. hidden modulo-127 check digit, added by Zint.
  2157. #### 6.1.6.2 Telepen Numeric
  2158. ![`zint -b TELEPEN_NUM --compliantheight -d
  2159. "466X33"`](images/telepen_num.svg){.lin}
  2160. Telepen Numeric allows compression of numeric data into a Telepen symbol. Data
  2161. can consist of pairs of numbers or pairs consisting of a numerical digit
  2162. followed an X character. For example: 466333 and 466X33 are valid codes whereas
  2163. 46X333 is not (the digit pair `"X3"` is not valid). Up to 136 digits can be
  2164. encoded. Telepen Numeric includes a hidden modulo-127 check digit which is added
  2165. by Zint.
  2166. ### 6.1.7 Code 39
  2167. #### 6.1.7.1 Standard Code 39 (ISO 16388)
  2168. ![`zint -b CODE39 --compliantheight -d "1A" --vers=1`](images/code39.svg){.lin}
  2169. Standard Code 39 was developed in 1974 by Intermec. Input data can be up to 86
  2170. characters in length and can include the characters 0-9, A-Z, dash (`-`), full
  2171. stop (`.`), space, asterisk (`*`), dollar (`$`), slash (`/`), plus (`+`) and
  2172. percent (`%`). The standard does not require a check digit but a modulo-43 check
  2173. digit can be added if desired by setting `--vers=1` (API `option_2 = 1`). To add
  2174. a check digit but not show it in the Human Readable Text, set `--vers=2` (API
  2175. `option_2 = 2`).
  2176. \clearpage
  2177. #### 6.1.7.2 Extended Code 39
  2178. ![`zint -b EXCODE39 --compliantheight -d
  2179. "123.45$@fd"`](images/excode39.svg){.lin}
  2180. Also known as Code 39e and Code39+, this symbology expands on Standard Code 39
  2181. to provide support for the full 7-bit ASCII character set. The check digit
  2182. options are the same as for [6.1.7.1 Standard Code 39 (ISO 16388)].
  2183. #### 6.1.7.3 Code 93
  2184. ![`zint -b CODE93 --compliantheight -d "C93"`](images/code93.svg){.lin}
  2185. A variation of Extended Code 39, Code 93 also supports full ASCII text,
  2186. accepting up to 123 characters. Two check characters are added by Zint. By
  2187. default these check characters are not shown in the Human Readable Text, but may
  2188. be shown by setting `--vers=1` (API `option_2 = 1`).
  2189. #### 6.1.7.4 PZN (Pharmazentralnummer)
  2190. ![`zint -b PZN --compliantheight -d "2758089"`](images/pzn.svg){.lin}
  2191. PZN is a Code 39 based symbology used by the pharmaceutical industry in Germany.
  2192. PZN encodes a 7-digit number to which Zint will add a modulo-11 check digit
  2193. (PZN8). Input less than 7 digits will be zero-filled. An 8-digit input can be
  2194. supplied in which case Zint will validate the check digit.
  2195. To encode a PZN7 (obsolete since 2013) instead set `--vers=1` (API
  2196. `option_2 = 1`) and supply up to 7 digits. As with PZN8, a modulo-11 check digit
  2197. will be added or if 7 digits supplied the check digit validated.
  2198. #### 6.1.7.5 LOGMARS
  2199. ![`zint -b LOGMARS --compliantheight -d "12345/ABCDE"
  2200. --vers=1`](images/logmars.svg){.lin}
  2201. LOGMARS (Logistics Applications of Automated Marking and Reading Symbols) is a
  2202. variation of the Code 39 symbology used by the U.S. Department of Defense.
  2203. LOGMARS encodes the same character set as [6.1.7.1 Standard Code 39 (ISO
  2204. 16388)], and the check digit options are also the same. Input is restricted to
  2205. a maximum of 30 characters.
  2206. #### 6.1.7.6 Code 32
  2207. ![`zint -b CODE32 --compliantheight -d "14352312"`](images/code32.svg){.lin}
  2208. A variation of Code 39 used by the Italian Ministry of Health ("Ministero della
  2209. Sanità") for encoding identifiers on pharmaceutical products. This symbology
  2210. requires a numeric input up to 8 digits in length. A check digit is added by
  2211. Zint.
  2212. #### 6.1.7.7 HIBC Code 39
  2213. ![`zint -b HIBC_39 --compliantheight -d "14352312"`](images/hibc_39.svg){.lin}
  2214. This variant adds a leading `'+'` character and a trailing modulo-49 check digit
  2215. to a standard Code 39 symbol as required by the Health Industry Barcode
  2216. standards.
  2217. #### 6.1.7.8 Vehicle Identification Number (VIN)
  2218. ![`zint -b VIN -d "2FTPX28L0XCA15511" --vers=1`](images/vin.svg){.lin}
  2219. A variation of Code 39 that for vehicle identification numbers used in North
  2220. America (first character `'1'` to `'5'`) has a check character verification
  2221. stage. A 17 character input (0-9, and A-Z excluding `'I'`, `'O'` and `'Q'`) is
  2222. required. An invisible Import character prefix `'I'` can be added by setting
  2223. `--vers=1` (API `option_2 = 1`).
  2224. ### 6.1.8 Codabar (EN 798)
  2225. ![`zint -b CODABAR --compliantheight -d "A37859B"`](images/codabar.svg){.lin}
  2226. Also known as NW-7, Monarch, ABC Codabar, USD-4, Ames Code and Code 27, this
  2227. symbology was developed in 1972 by Monarch Marketing Systems for retail
  2228. purposes. The American Blood Commission adopted Codabar in 1977 as the standard
  2229. symbology for blood identification. Codabar can encode up to 103 characters
  2230. starting and ending with the letters A-D and containing between these letters
  2231. the numbers 0-9, dash (`-`), dollar (`$`), colon (`:`), slash (`/`), full stop
  2232. (`.`) or plus (`+`). No check character is generated by default, but a modulo-16
  2233. one can be added by setting `--vers=1` (API `option_2 = 1`). To have the check
  2234. character appear in the Human Readable Text, set `--vers=2` (API
  2235. `option_2 = 2`).
  2236. ### 6.1.9 Pharmacode
  2237. ![`zint -b PHARMA --compliantheight -d "130170"`](images/pharma.svg){.lin}
  2238. Developed by Laetus, Pharmacode is used for the identification of
  2239. pharmaceuticals. The symbology is able to encode whole numbers between 3 and
  2240. 131070.
  2241. ### 6.1.10 Code 128
  2242. #### 6.1.10.1 Standard Code 128 (ISO 15417)
  2243. ![`zint -b CODE128 --bind -d "130170X178"`](images/code128.svg){.lin}
  2244. One of the most ubiquitous one-dimensional barcode symbologies, Code 128 was
  2245. developed in 1981 by Computer Identics. This symbology supports full ASCII text
  2246. and uses a three-Code Set system to compress the data into a smaller symbol.
  2247. Zint automatically switches between Code Sets A, B and C (but see below) and
  2248. adds a hidden modulo-103 check digit.
  2249. Code 128 is the default barcode symbology used by Zint. In addition Zint
  2250. supports the encoding of ISO/IEC 8859-1 (non-English) characters in Code 128
  2251. symbols. The ISO/IEC 8859-1 character set is shown in Annex [A.2 Latin Alphabet
  2252. No. 1 (ISO/IEC 8859-1)].
  2253. Manual switching of Code Sets is possible using the `--extraesc` option (API
  2254. `input_mode |= EXTRA_ESCAPE_MODE`), which apart from processing normal escape
  2255. sequences also processes the Code 128-specific escapes `\^A`, `\^B`, `\^C` and
  2256. `\^@` (the latter turns off manual Code Set selection). For instance the
  2257. following will force switching to Code Set B for the data `"5678"` (normally
  2258. Code Set C would be used throughout):
  2259. ```bash
  2260. zint -b CODE128 -d "1234\^B5678" --extraesc
  2261. ```
  2262. The manually selected Code Set will apply until the next Code Set escape
  2263. sequence or until a `\^@`, with the exception that data that cannot be
  2264. represented in that Code Set will be switched as appropriate. If the data
  2265. contains an extra escape sequence, it can be escaped by doubling the caret
  2266. (`^`). For instance
  2267. ```bash
  2268. zint -b CODE128 -d "\^AABC\^^BDEF" --extraesc
  2269. ```
  2270. will encode the data `"ABC\^BDEF"` in Code Set A.
  2271. There is also the extra escape `\^1`, which will encode a special Function Code
  2272. 1 character (FNC1) anywhere you chose in the data, for instance
  2273. ```bash
  2274. zint -b CODE128 -d "A\^1BC\^1DEF" --extraesc
  2275. ```
  2276. Zint can encode a maximum of 102 symbol characters, which allows for e.g. 202
  2277. all-numeric or 101 all-uppercase characters. Sizes above 120 digits (60
  2278. alphanumerics) are not recommended.
  2279. #### 6.1.10.2 Code 128 Suppress Code Set C (Code Sets A and B only)
  2280. ![`zint -b CODE128AB -d "130170X178"`](images/code128ab.svg){.lin}
  2281. It is sometimes advantageous to stop Code 128 from using Code Set C which
  2282. compresses numerical data. The `BARCODE_CODE128AB`[^14] variant (symbology 60)
  2283. suppresses Code Set C in favour of Code Sets A and B.
  2284. Note that the special extra escapes mentioned above are not available for this
  2285. variant (nor for any other).
  2286. [^14]: `BARCODE_CODE128AB` previously used the name `BARCODE_CODE128B`, which is
  2287. still recognised.
  2288. #### 6.1.10.3 GS1-128
  2289. ![`zint -b GS1_128 --compliantheight -d
  2290. "[01]98898765432106[3202]012345[15]991231"`](images/gs1_128.svg){.lin}
  2291. A variation of Code 128 previously known as UCC/EAN-128, this symbology is
  2292. defined by the GS1 General Specifications. Application Identifiers (AIs) should
  2293. be entered using [square bracket] notation. These will be converted to
  2294. parentheses (round brackets) for the Human Readable Text. This will allow round
  2295. brackets to be used in the data strings to be encoded.
  2296. For compatibility with data entry in other systems, if the data does not include
  2297. round brackets, the option `--gs1parens` (API `input_mode |= GS1PARENS_MODE`)
  2298. may be used to signal that AIs are encased in round brackets instead of square
  2299. ones.
  2300. Fixed length data should be entered at the appropriate length for correct
  2301. encoding. GS1-128 does not support extended ASCII (ISO/IEC 8859-1) characters.
  2302. Check digits for GTIN data AI (01) are not generated and need to be included in
  2303. the input data. The following is an example of a valid GS1-128 input:
  2304. ```bash
  2305. zint -b 16 -d "[01]98898765432106[3202]012345[15]991231"
  2306. ```
  2307. or using the `--gs1parens` option:
  2308. ```bash
  2309. zint -b 16 --gs1parens -d "(01)98898765432106(3202)012345(15)991231"
  2310. ```
  2311. #### 6.1.10.4 EAN-14
  2312. ![`zint -b EAN14 --compliantheight -d "9889876543210"`](images/ean14.svg){.lin}
  2313. A shorter version of GS1-128 which encodes GTIN data only. A 13-digit number is
  2314. required. The GTIN check digit and HRT-only AI "(01)" are added by Zint.
  2315. #### 6.1.10.5 NVE-18 (SSCC-18)
  2316. ![`zint -b NVE18 --compliantheight -d
  2317. "37612345000001003"`](images/nve18.svg){.lin}
  2318. A variation of Code 128 the 'Nummer der Versandeinheit' standard, also known as
  2319. SSCC-18 (Serial Shipping Container Code), includes both a visible modulo-10 and
  2320. a hidden modulo-103 check digit. NVE-18 requires a 17-digit numerical input.
  2321. Check digits and HRT-only AI "(00)" are added by Zint.
  2322. #### 6.1.10.6 HIBC Code 128
  2323. ![`zint -b HIBC_128 -d "A123BJC5D6E71"`](images/hibc_128.svg){.lin}
  2324. This option adds a leading `'+'` character and a trailing modulo-49 check digit
  2325. to a standard Code 128 symbol as required by the Health Industry Barcode
  2326. standards.
  2327. #### 6.1.10.7 DPD Code
  2328. ![`zint -b DPD --compliantheight -d
  2329. "000393206219912345678101040"`](images/dpd.svg){.lin}
  2330. Another variation of Code 128 as used by DPD (Deutscher Paketdienst). Requires a
  2331. 27 or 28 character input. For 28 character input, the first character is an
  2332. identification tag (Barcode ID), which should usually be `"%"` (ASCII 37). If 27
  2333. characters are supplied, `"%"` will be prefixed by Zint (except if marked as a
  2334. "relabel", see below). The rest of the 27-character input must be alphanumeric,
  2335. and is of the form:
  2336. -----------------------------------------------------------------------
  2337. Destination Post Tracking Number Service Destination Country
  2338. Code Code Code
  2339. ----------------- ------------------ ---------- --------------------
  2340. PPPPPPP TTTTTTTTTTTTTT SSS CCC
  2341. (7 alphanumerics) (14 alphanumerics) (3 digits) (3-digit ISO 3166-1)
  2342. -----------------------------------------------------------------------
  2343. Table: {#tbl:dpd_input_fields tag=": DPD Input Fields"}
  2344. A warning will be generated if the Service Code, the Destination Country Code,
  2345. or the last 10 characters of the Tracking Number are non-numeric.
  2346. Zint formats the Human Readable Text as specified by DPD, leaving out the
  2347. identication tag, and adds a modulo-36 check character to the text (not to the
  2348. barcode itself), thus:
  2349. `PPPP PPP TTTT TTTT TTTT TT SSS CCC D`
  2350. By default a top boundary bar is added, with default width 3X. The width can be
  2351. overridden using `--border` (API `border_width`). For a symbol with no top
  2352. boundary bar, explicitly set the border type to bindtop (or bind or box) and
  2353. leave the border width 0.
  2354. A DPD Code can be marked as a "relabel" by specifying `--vers=1` (API
  2355. `option_2 = 1`), which omits the identification tag and prints the barcode at
  2356. half height. In this case, an input of 27 alphanumeric characters is required.
  2357. \clearpage
  2358. #### 6.1.10.8 UPU S10
  2359. ![`zint -b UPU_S10 --compliantheight -d
  2360. "EE876543216CA"`](images/upu_s10.svg){.lin}
  2361. The Universal Postal Union S10 variant of Code 128 encodes 13 characters in the
  2362. format `"SSNNNNNNNNXCC"`, where `"SS"` is a two-character alphabetic service
  2363. indicator, `"NNNNNNNN"` is an 8-digit serial number, `"X"` is a modulo-11 check
  2364. digit, and `"CC"` is a two-character ISO 3166-1 country code.
  2365. The check digit may be omitted in which case Zint will add it. Warnings will be
  2366. generated if the service indicator is non-standard or the country code is not
  2367. ISO 3361-1.
  2368. ### 6.1.11 GS1 DataBar (ISO 24724)
  2369. Previously known as RSS (Reduced Spaced Symbology), these symbols are due to
  2370. replace GS1-128 symbols in accordance with the GS1 General Specifications. If a
  2371. GS1 DataBar symbol is to be printed with a 2D component as specified in ISO/IEC
  2372. 24723 set `--mode=2` (API `option_1 = 2`). See [6.3 GS1 Composite Symbols (ISO
  2373. 24723)] to find out how to generate DataBar symbols with 2D components.
  2374. #### 6.1.11.1 GS1 DataBar Omnidirectional and GS1 DataBar Truncated
  2375. ![`zint -b DBAR_OMN --compliantheight -d
  2376. "0950110153001"`](images/dbar_omn.svg){.lin}
  2377. Previously known as RSS-14 this standard encodes a 13-digit item code. A check
  2378. digit and HRT-only Application Identifier of "(01)" are added by Zint. (A
  2379. 14-digit code that appends the check digit may be given, in which case the check
  2380. digit will be verified.)
  2381. GS1 DataBar Omnidirectional symbols should have a height of 33 or greater. To
  2382. produce a GS1 DataBar Truncated symbol set the symbol height to a value between
  2383. 13 and 32. Truncated symbols may not be scannable by omnidirectional scanners.
  2384. ![`zint -b DBAR_OMN -d "0950110153001"
  2385. --height=13`](images/dbar_truncated.svg){.lin}
  2386. #### 6.1.11.2 GS1 DataBar Limited
  2387. ![`zint -b DBAR_LTD --compliantheight -d
  2388. "0950110153001"`](images/dbar_ltd.svg){.lin}
  2389. Previously known as RSS Limited this standard encodes a 13-digit item code and
  2390. can be used in the same way as GS1 DataBar Omnidirectional above. GS1 DataBar
  2391. Limited, however, is limited to data starting with digits 0 and 1 (i.e. numbers
  2392. in the range 0 to 1999999999999). As with GS1 DataBar Omnidirectional a check
  2393. digit and HRT-only Application Identifier of "(01)" are added by Zint, and a
  2394. 14-digit code may be given in which case the check digit will be verified.
  2395. #### 6.1.11.3 GS1 DataBar Expanded
  2396. ![`zint -b DBAR_EXP --compliantheight -d
  2397. "[01]98898765432106[3202]012345[15]991231"`](images/dbar_exp.svg){.lin}
  2398. Previously known as RSS Expanded this is a variable length symbology capable of
  2399. encoding data from a number of AIs in a single symbol. AIs should be encased in
  2400. [square brackets] in the input data, which will be converted to parentheses
  2401. (round brackets) before being included in the Human Readable Text attached to
  2402. the symbol. This method allows the inclusion of parentheses in the data to be
  2403. encoded. If the data does not include parentheses, the AIs may alternatively be
  2404. encased in parentheses using the `--gs1parens` switch. See [6.1.10.3 GS1-128].
  2405. GTIN data AI (01) should also include the check digit data as this is not
  2406. calculated by Zint when this symbology is encoded. Fixed length data should be
  2407. entered at the appropriate length for correct encoding. The following is an
  2408. example of a valid GS1 DataBar Expanded input:
  2409. ```bash
  2410. zint -b 31 -d "[01]98898765432106[3202]012345[15]991231"
  2411. ```
  2412. ### 6.1.12 Korea Post Barcode
  2413. ![`zint -b KOREAPOST -d "923457"`](images/koreapost.svg){.lin}
  2414. The Korean Postal Barcode is used to encode a 6-digit number and includes one
  2415. check digit.
  2416. ### 6.1.13 Channel Code
  2417. ![`zint -b CHANNEL -d "453678" --compliantheight`](images/channel.svg){.lin}
  2418. A highly compressed symbol for numeric data. The number of channels in the
  2419. symbol can be between 3 and 8 and this can be specified by setting the value of
  2420. the `--vers` option (API `option_2`). It can also be determined by the length of
  2421. the input data: e.g. a three character input string generates a 4 channel code
  2422. by default.
  2423. The maximum values permitted depend on the number of channels used as shown in
  2424. the table below:
  2425. | Channels | Minimum Value | Maximum Value
  2426. |:---------|:--------------|:-------------
  2427. | 3 | 00 | 26
  2428. | 4 | 000 | 292
  2429. | 5 | 0000 | 3493
  2430. | 6 | 00000 | 44072
  2431. | 7 | 000000 | 576688
  2432. | 8 | 0000000 | 7742862
  2433. Table: {#tbl:channel_maxima tag=": Channel Value Ranges"}
  2434. ### 6.1.14 BC412 (SEMI T1-95)
  2435. ![`zint -b BC412 -d "AQ45670" --compliantheight`](images/bc412.svg){.lin}
  2436. Designed by IBM for marking silicon wafers, each BC412 character is represented
  2437. by 4 bars of a single size, interleaved with 4 spaces of varying sizes that
  2438. total 8 (hence 4 bars in 12). Zint implements the SEMI T1-95 standard, where
  2439. input must be alphanumeric, excluding the letter `O`, and must be from 7 to 18
  2440. characters in length. A single check character is added by Zint, appearing in
  2441. the 2nd character position. Lowercase input is automatically made uppercase.
  2442. \clearpage
  2443. ## 6.2 Stacked Symbologies
  2444. ### 6.2.1 Basic Symbol Stacking
  2445. An early innovation to get more information into a symbol, used primarily in the
  2446. vehicle industry, is to simply stack one-dimensional codes on top of each other.
  2447. This can be achieved at the command prompt by giving more than one set of input
  2448. data. For example
  2449. ```bash
  2450. zint -d "This" -d "That"
  2451. ```
  2452. will draw two Code 128 symbols, one on top of the other. The same result can be
  2453. achieved using the API by executing the `ZBarcode_Encode()` function more than
  2454. once on a symbol. For example:
  2455. ```c
  2456. my_symbol->symbology = BARCODE_CODE128;
  2457. error = ZBarcode_Encode(my_symbol, "This", 0);
  2458. error = ZBarcode_Encode(my_symbol, "That", 0);
  2459. error = ZBarcode_Print(my_symbol);
  2460. ```
  2461. ![`zint -d "This" -d "That"`](images/code128_stacked.svg){.lin}
  2462. Note that the Human Readable Text will be that of the last data, so it's best to
  2463. use the option `--notext` (API `show_hrt = 0`).
  2464. The stacked barcode rows can be separated by row separator bars by specifying
  2465. `--bind` (API `output_options |= BARCODE_BIND`). The height of the row separator
  2466. bars in integral multiples of the X-dimension (minimum and default 1, maximum 4)
  2467. can be set by `--separator` (API `option_3`):
  2468. ```bash
  2469. zint --bind --notext --separator=2 -d "This" -d "That"
  2470. ```
  2471. ![`zint --notext --bind --separator=2 -d "This" -d
  2472. "That"`](images/code128_stacked_sep2.svg){.lin}
  2473. A more sophisticated method is to use some type of line indexing which indicates
  2474. to the barcode reader which order the stacked symbols should be read in. This is
  2475. demonstrated by the symbologies below.
  2476. ### 6.2.2 Codablock-F
  2477. ![`zint -b CODABLOCKF -d "CODABLOCK F Symbology"
  2478. --rows=3`](images/codablockf.svg){.lin}
  2479. This is a stacked symbology based on Code 128 which can encode Latin-1 data up
  2480. to a maximum length of 2726 symbol characters, meaning for instance up to 2726
  2481. all ASCII characters, or 5452 all numeric, or up to 1363 all extended ASCII
  2482. (ISO/IEC 8859-1).
  2483. The width of the Codablock-F symbol can be set using the `--cols` option (API
  2484. `option_2`), to a value between 9 and 67. The height (number of rows) can be set
  2485. using the `--rows` option (API `option_1`), with a maximum of 44. Zint does not
  2486. currently support encoding of GS1 data in Codablock-F symbols.
  2487. A separate symbology ID (`BARCODE_HIBC_BLOCKF`) can be used to encode Health
  2488. Industry Barcode (HIBC) data which adds a leading `'+'` character and a
  2489. modulo-49 check digit to the encoded data.
  2490. ### 6.2.3 Code 16K (EN 12323)
  2491. ![`zint -b CODE16K --compliantheight -d
  2492. "ab0123456789"`](images/code16k.svg){.lin}
  2493. Code 16K uses a Code 128 based system which can stack up to 16 rows in a block.
  2494. This gives a maximum data capacity of 77 characters or 154 numerical digits and
  2495. includes two modulo-107 check digits. Code 16K also supports ISO/IEC 8859-1
  2496. character encoding in the same manner as Code 128. GS1 data encoding is also
  2497. supported. The minimum number of rows to use can be set using the `--rows`
  2498. option (API `option_1`), with values from 2 to 16.
  2499. ### 6.2.4 PDF417 (ISO 15438)
  2500. ![`zint -b PDF417 -d "PDF417"`](images/pdf417.svg){.lin}
  2501. Heavily used in the parcel industry, the PDF417 symbology can encode a vast
  2502. amount of data into a small space. Zint supports encoding up to the ISO standard
  2503. maximum symbol size of 925 codewords which (at error correction level 0) allows
  2504. a maximum data size of 1850 text characters, or 2710 digits.
  2505. The width of the generated PDF417 symbol can be specified at the command line
  2506. using the `--cols` switch (API `option_2`) followed by a number between 1 and
  2507. 30, the number of rows using the `--rows` switch (API `option_3`) followed by a
  2508. number between 3 and 90, and the amount of error correction information can be
  2509. specified by using the `--secure` switch (API `option_1`) followed by a number
  2510. between 0 and 8 where the number of codewords used for error correction is
  2511. determined by `2^(value + 1)`. The default level of error correction is
  2512. determined by the amount of data being encoded.
  2513. This symbology uses Latin-1 character encoding by default but also supports the
  2514. ECI encoding mechanism. A separate symbology ID (`BARCODE_HIBC_PDF`) can be used
  2515. to encode Health Industry Barcode (HIBC) data.
  2516. For a faster but less optimal encoding, the `--fast` option (API `input_mode |=
  2517. FAST_MODE`) may be used.
  2518. PDF417 supports Structured Append of up to 99,999 symbols and an optional
  2519. numeric ID of up to 30 digits, which can be set by using the `--structapp`
  2520. option (see [4.17 Structured Append]) (API `structapp`). The ID consists of up
  2521. to 10 triplets, each ranging from `"000"` to `"899"`. For instance `"123456789"`
  2522. would be a valid ID of 3 triplets. However `"123456900"` would not, as the last
  2523. triplet `"900"` exceeds `"899"`. The triplets are 0-filled, for instance
  2524. `"1234"` becomes `"123004"`. If an ID is not given, no ID is encoded.
  2525. ### 6.2.5 Compact PDF417 (ISO 15438)
  2526. ![`zint -b PDF417COMP -d "PDF417"`](images/pdf417comp.svg){.lin}
  2527. Previously known as Truncated PDF417, Compact PDF417 omits some per-row overhead
  2528. to produce a narrower but less robust symbol. Options are the same as for PDF417
  2529. above.
  2530. ### 6.2.6 MicroPDF417 (ISO 24728)
  2531. ![`zint -b MICROPDF417 -d "12345678"`](images/micropdf417.svg){.lin}
  2532. A variation of the PDF417 standard, MicroPDF417 is intended for applications
  2533. where symbol size needs to be kept to a minimum. 34 predefined symbol sizes are
  2534. available with 1 - 4 columns and 4 - 44 rows. The maximum amount a MicroPDF417
  2535. symbol can hold is 250 alphanumeric characters or 366 digits. The amount of
  2536. error correction used is dependent on symbol size. The number of columns used
  2537. can be determined using the `--cols` switch (API `option_2`) as with PDF417.
  2538. This symbology uses Latin-1 character encoding by default but also supports the
  2539. ECI encoding mechanism. A separate symbology ID (`BARCODE_HIBC_MICPDF`) can be
  2540. used to encode Health Industry Barcode (HIBC) data. MicroPDF417 supports
  2541. `FAST_MODE` and Structured Append the same as PDF417, for which see details.
  2542. ### 6.2.7 GS1 DataBar Stacked (ISO 24724)
  2543. #### 6.2.7.1 GS1 DataBar Stacked
  2544. ![`zint -b DBAR_STK --compliantheight -d
  2545. "9889876543210"`](images/dbar_stk.svg){.lin}
  2546. A stacked variation of the GS1 DataBar Truncated symbol requiring the same input
  2547. (see [6.1.11.1 GS1 DataBar Omnidirectional and GS1 DataBar Truncated]), this
  2548. symbol is the same as the following GS1 DataBar Stacked Omnidirectional symbol
  2549. except that its height is reduced and its central separator is a single row,
  2550. making it suitable for small items when omnidirectional scanning is not
  2551. required. It can be generated with a two-dimensional component to make a
  2552. composite symbol.
  2553. #### 6.2.7.2 GS1 DataBar Stacked Omnidirectional
  2554. ![`zint -b DBAR_OMNSTK --compliantheight -d
  2555. "9889876543210"`](images/dbar_omnstk.svg){.lin}
  2556. A stacked variation of the GS1 DataBar Omnidirectional symbol requiring the same
  2557. input (see [6.1.11.1 GS1 DataBar Omnidirectional and GS1 DataBar Truncated]).
  2558. The data is encoded in two rows of bars with a central 3-row separator. This
  2559. symbol can be generated with a two-dimensional component to make a composite
  2560. symbol.
  2561. #### 6.2.7.3 GS1 DataBar Expanded Stacked
  2562. ![`zint -b DBAR_EXPSTK --compliantheight -d
  2563. "[01]98898765432106[3202]012345[15]991231"`](images/dbar_expstk.svg){.lin}
  2564. A stacked variation of the GS1 DataBar Expanded symbol for smaller packages.
  2565. Input is the same as for GS1 DataBar Expanded (see [6.1.11.3 GS1 DataBar
  2566. Expanded]). In addition the width of the symbol can be altered using the
  2567. `--cols` switch (API `option_2`). In this case the number of columns (values 1
  2568. to 11) relates to the number of character pairs on each row of the symbol.
  2569. Alternatively the `--rows` switch (API `option_3`) can be used to specify the
  2570. maximum number of rows (values 2 to 11), and the number of columns will be
  2571. adjusted accordingly. This symbol can be generated with a two-dimensional
  2572. component to make a composite symbol. For symbols with a 2D component the number
  2573. of columns must be at least 2.
  2574. ### 6.2.8 Code 49
  2575. ![`zint -b CODE49 --compliantheight -d
  2576. "MULTIPLE ROWS IN CODE 49"`](images/code49.svg){.lin}
  2577. Developed in 1987 at Intermec, Code 49 is a cross between UPC and Code 39. It is
  2578. one of the earliest stacked symbologies and influenced the design of Code 16K a
  2579. few years later. It supports full 7-bit ASCII input up to a maximum of 49
  2580. characters or 81 numeric digits. GS1 data encoding is also supported. The
  2581. minimum number of rows to use can be set using the `--rows` option (API
  2582. `option_1`), with values from 2 to 8.
  2583. \clearpage
  2584. ## 6.3 GS1 Composite Symbols (ISO 24723)
  2585. GS1 Composite symbols employ a mixture of components to give more comprehensive
  2586. information about a product. The permissible contents of a composite symbol is
  2587. determined by the terms of the GS1 General Specifications. Composite symbols
  2588. consist of a linear component which can be an EAN, UPC, GS1-128 or GS1 DataBar
  2589. symbol, a two-dimensional (2D) component which is based on PDF417 or
  2590. MicroPDF417, and a separator pattern. The type of linear component to be used is
  2591. determined using the `-b` or `--barcode` switch (API `symbology`) as with other
  2592. encoding methods. Valid values are shown below.
  2593. ---------------------------------------------------------------------------
  2594. Numeric Name Barcode Name
  2595. Value
  2596. ------- ------------------------ ----------------------------------------
  2597. 130 `BARCODE_EANX_CC` GS1 Composite Symbol with EAN linear
  2598. component
  2599. 131 `BARCODE_GS1_128_CC` GS1 Composite Symbol with GS1-128 linear
  2600. component
  2601. 132 `BARCODE_DBAR_OMN_CC` GS1 Composite Symbol with GS1 DataBar
  2602. Omnidirectional linear component
  2603. 133 `BARCODE_DBAR_LTD_CC` GS1 Composite Symbol with GS1 DataBar
  2604. Limited linear component
  2605. 134 `BARCODE_DBAR_EXP_CC` GS1 Composite Symbol with GS1 DataBar
  2606. Expanded linear component
  2607. 135 `BARCODE_UPCA_CC` GS1 Composite Symbol with UPC-A linear
  2608. component
  2609. 136 `BARCODE_UPCE_CC` GS1 Composite Symbol with UPC-E linear
  2610. component
  2611. 137 `BARCODE_DBAR_STK_CC` GS1 Composite Symbol with GS1 DataBar
  2612. Stacked component
  2613. 138 `BARCODE_DBAR_OMNSTK_CC` GS1 Composite Symbol with GS1 DataBar
  2614. Stacked Omnidirectional component
  2615. 139 `BARCODE_DBAR_EXPSTK_CC` GS1 Composite Symbol with GS1 DataBar
  2616. Expanded Stacked component
  2617. ---------------------------------------------------------------------------
  2618. Table: {#tbl:composite_symbologies tag=": GS1 Composite Symbology Values"}
  2619. The data to be encoded in the linear component of a composite symbol should be
  2620. entered into a primary string with the data for the 2D component being entered
  2621. in the normal way. To do this at the command prompt use the `--primary` switch
  2622. (API `primary`). For example:
  2623. ```bash
  2624. zint -b EANX_CC --mode=1 --primary=331234567890 -d "[99]1234-abcd"
  2625. ```
  2626. This creates an EAN-13 linear component with the data `"331234567890"` and a 2D
  2627. CC-A (see [below][6.3.1 CC-A]) component with the data `"(99)1234-abcd"`. The
  2628. same results can be achieved using the API as shown below:
  2629. ```c
  2630. my_symbol->symbology = BARCODE_EANX_CC;
  2631. my_symbol->option_1 = 1;
  2632. strcpy(my_symbol->primary, "331234567890");
  2633. ZBarcode_Encode_and_Print(my_symbol, "[99]1234-abcd", 0, 0);
  2634. ```
  2635. EAN-2 and EAN-5 add-on data can be used with EAN and UPC symbols using the +
  2636. symbol as described in sections [6.1.3 UPC (Universal Product Code) (ISO 15420)]
  2637. and [6.1.4 EAN (European Article Number) (ISO 15420)].
  2638. The 2D component of a composite symbol can use one of three systems: CC-A, CC-B
  2639. and CC-C, as described below. The 2D component type can be selected
  2640. automatically by Zint dependent on the length of the input string. Alternatively
  2641. the three methods can be accessed using the `--mode` prompt (API `option_1`)
  2642. followed by 1, 2 or 3 for CC-A, CC-B or CC-C respectively.
  2643. ### 6.3.1 CC-A
  2644. ![`zint -b EANX_CC --compliantheight -d "[99]1234-abcd" --mode=1
  2645. --primary=331234567890`](images/eanx_cc_a.svg){.upcean}
  2646. This system uses a variation of MicroPDF417 which is optimised to fit into a
  2647. small space. The size of the 2D component and the amount of error correction is
  2648. determined by the amount of data to be encoded and the type of linear component
  2649. which is being used. CC-A can encode up to 56 numeric digits or an alphanumeric
  2650. string of shorter length. To select CC-A use `--mode=1` (API `option_1 = 1`).
  2651. ### 6.3.2 CC-B
  2652. ![`zint -b EANX_CC --compliantheight -d "[99]1234-abcd" --mode=2
  2653. --primary=331234567890`](images/eanx_cc_b.svg){.upcean}
  2654. This system uses MicroPDF417 to encode the 2D component. The size of the 2D
  2655. component and the amount of error correction is determined by the amount of data
  2656. to be encoded and the type of linear component which is being used. CC-B can
  2657. encode up to 338 numeric digits or an alphanumeric string of shorter length. To
  2658. select CC-B use `--mode=2` (API `option_1 = 2`).
  2659. ### 6.3.3 CC-C
  2660. ![`zint -b GS1_128_CC --compliantheight -d "[99]1234-abcd" --mode=3
  2661. --primary="[01]03312345678903"`](images/gs1_128_cc_c.svg){.upcean}
  2662. This system uses PDF417 and can only be used in conjunction with a GS1-128
  2663. linear component. CC-C can encode up to 2361 numeric digits or an alphanumeric
  2664. string of shorter length. To select CC-C use `--mode=3` (API `option_1 = 3`).
  2665. \clearpage
  2666. ## 6.4 Two-Track Symbols
  2667. ### 6.4.1 Two-Track Pharmacode
  2668. ![`zint -b PHARMA_TWO --compliantheight -d
  2669. "29876543"`](images/pharma_two.svg){.trk}
  2670. Developed by Laetus, Pharmacode Two-Track is an alternative system to Pharmacode
  2671. One-Track (see [6.1.9 Pharmacode]) used for the identification of
  2672. pharmaceuticals. The symbology is able to encode whole numbers between 4 and
  2673. 64570080.
  2674. ### 6.4.2 POSTNET
  2675. ![`zint -b POSTNET --compliantheight -d
  2676. "12345678901"`](images/postnet.svg){.trk}
  2677. Used by the United States Postal Service until 2009, the POSTNET barcode was
  2678. used for encoding zip-codes on mail items. POSTNET uses numerical input data and
  2679. includes a modulo-10 check digit. While Zint will encode POSTNET symbols of up
  2680. to 38 digits in length, standard lengths as used by USPS were `PostNet6`
  2681. (5-digit ZIP input), `PostNet10` (5-digit ZIP + 4-digit user data) and
  2682. `PostNet12` (5-digit ZIP + 6-digit user data), and a warning will be issued if
  2683. the input length is not one of these.
  2684. ### 6.4.3 PLANET
  2685. ![`zint -b PLANET --compliantheight -d
  2686. "4012345235636"`](images/planet.svg){.trk}
  2687. Used by the United States Postal Service until 2009, the PLANET (Postal Alpha
  2688. Numeric Encoding Technique) barcode was used for encoding routing data on mail
  2689. items. PLANET uses numerical input data and includes a modulo-10 check digit.
  2690. While Zint will encode PLANET symbols of up to 38 digits in length, standard
  2691. lengths used by USPS were `Planet12` (11-digit input) and `Planet14` (13-digit
  2692. input), and as with POSTNET a warning will be issued if the length is not one of
  2693. these.
  2694. ### 6.4.4 Brazilian CEPNet
  2695. ![`zint -b CEPNET --compliantheight -d "12345678"`](images/cepnet.svg){.trk}
  2696. Based on POSTNET, the CEPNet symbol is used by Correios, the Brazilian postal
  2697. service, to encode CEP (Código de Endereçamento Postal) numbers on mail items.
  2698. Input should consist of eight digits with the check digit being automatically
  2699. added by Zint.
  2700. ### 6.4.5 DX Film Edge Barcode
  2701. ![`zint -b DXFILMEDGE --compliantheight -d
  2702. "112-1/10A"`](images/dxfilmedge.svg){.trk}
  2703. Introduced by Kodak in the 1980s, the DX (Digital Index) barcode is printed on
  2704. the bottom edge of 35mm film to aid in the reordering and post-processing of
  2705. prints.
  2706. The data can be in two parts. The first part (required) is the "DX number",
  2707. identifying the manufacturer and film type - the National Association of
  2708. Photographic Manufacturers (NAPM) number. The second part, which is
  2709. optional and if present is separated from the first by a slash (`/`), gives the
  2710. frame number.
  2711. The DX number is in either of two formats. The first format is a number of 1 to
  2712. 4 digits ("DX Extract") or 6 digits ("DX Full"), but for the 6-digit version the
  2713. first and last digit are ignored, leaving a 4-digit DX Extract number in any
  2714. case, which must be in the range 16 to 2047. The second format "NNN-NN"
  2715. represents the DX Extract as two numbers separated by a dash (`-`), the first
  2716. number being 1 to 3 digits (range 1 to 127) and the second 1 to 2 digits (range
  2717. 0 to 15).[^15]
  2718. The optional frame number is a number in the range 0 to 63, and may have a half
  2719. frame indicator "A" appended. Special character sequences (with or without a
  2720. half frame indicator appended) may also be used: "S" or "X" means frame number
  2721. 62, "K" or "00" means frame number 63, and "F" means frame number 0.
  2722. A parity bit is automatically added by Zint.
  2723. [^15]: The DX Number may be looked up in The (Modified) Big Film Database at
  2724. [https://thebigfilmdatabase.merinorus.com](
  2725. https://thebigfilmdatabase.merinorus.com).
  2726. \clearpage
  2727. ## 6.5 4-State Postal Codes
  2728. ### 6.5.1 Australia Post 4-State Symbols
  2729. #### 6.5.1.1 Customer Barcodes
  2730. ![`zint -b AUSPOST --compliantheight -d "96184209"`](images/auspost.svg){.trk}
  2731. Australia Post Standard Customer Barcode, Customer Barcode 2 and Customer
  2732. Barcode 3 are 37-bar, 52-bar and 67-bar specifications respectively, developed
  2733. by Australia Post for printing Delivery Point ID (DPID) and customer information
  2734. on mail items. Valid data characters are 0-9, A-Z, a-z, space and hash (#). A
  2735. Format Control Code (FCC) is added by Zint and should not be included in the
  2736. input data. Reed-Solomon error correction data is generated by Zint. Encoding
  2737. behaviour is determined by the length of the input data according to the formula
  2738. shown in the following table.
  2739. -------------------------------------------------------------
  2740. Input Required Input Format Symbol FCC Encoding
  2741. Length Length Table
  2742. ------ ------------------------- ------ --- --------
  2743. 8 `99999999` 37-bar 11 None
  2744. 13 `99999999AAAAA` 52-bar 59 C
  2745. 16 `9999999999999999` 52-bar 59 N
  2746. 18 `99999999AAAAAAAAAA` 67-bar 62 C
  2747. 23 `99999999999999999999999` 67-bar 62 N
  2748. -------------------------------------------------------------
  2749. Table: {#tbl:auspost_input_formats tag=": Australia Post Input Formats"}
  2750. #### 6.5.1.2 Reply Paid Barcode
  2751. ![`zint -b AUSREPLY --compliantheight -d "12345678"`](images/ausreply.svg){.trk}
  2752. A Reply Paid version of the Australia Post 4-State Barcode (FCC 45) which
  2753. requires an 8-digit DPID input.
  2754. #### 6.5.1.3 Routing Barcode
  2755. ![`zint -b AUSROUTE --compliantheight -d "34567890"`](images/ausroute.svg){.trk}
  2756. A Routing version of the Australia Post 4-State Barcode (FCC 87) which requires
  2757. an 8-digit DPID input.
  2758. #### 6.5.1.4 Redirect Barcode
  2759. ![`zint -b AUSREDIRECT --compliantheight -d
  2760. "98765432"`](images/ausredirect.svg){.trk}
  2761. A Redirection version of the Australia Post 4-State Barcode (FCC 92) which
  2762. requires an 8-digit DPID input.
  2763. ### 6.5.2 Dutch Post KIX Code
  2764. ![`zint -b KIX --compliantheight -d "2500GG30250"`](images/kix.svg){.trk}
  2765. This symbology is used by Royal Dutch TPG Post (Netherlands) for Postal code and
  2766. automatic mail sorting. Data input can consist of numbers 0-9 and letters A-Z
  2767. and needs to be 11 characters in length. No check digit is included.
  2768. ### 6.5.3 Royal Mail 4-State Customer Code (RM4SCC)
  2769. ![`zint -b RM4SCC --compliantheight -d "W1J0TR01"`](images/rm4scc.svg){.trk}
  2770. The RM4SCC standard is used by the Royal Mail in the UK to encode postcode and
  2771. customer data on mail items. Data input can consist of numbers 0-9 and letters
  2772. A-Z and usually includes delivery postcode followed by house number. For example
  2773. `"W1J0TR01"` for 1 Piccadilly Circus in London. Check digit data is generated by
  2774. Zint.
  2775. ### 6.5.4 Royal Mail 4-State Mailmark
  2776. ![`zint -b MAILMARK_4S --compliantheight -d
  2777. "1100000000000XY11"`](images/mailmark_4s.svg){.trk}
  2778. Developed in 2014 as a replacement for RM4SCC this 4-state symbol includes Reed-
  2779. Solomon error correction. Input is a pre-formatted alphanumeric string of 22
  2780. (for Barcode C) or 26 (for Barcode L) characters, producing a symbol with 66 or
  2781. 78 bars respectively. The rules for the input data are complex, as summarized in
  2782. the following table.
  2783. ---------------------------------------------------------------------------
  2784. Format Version Class Supply Chain ID Item ID Destination+DPS
  2785. ID
  2786. ------- ------- ----------- --------------- -------- -----------------
  2787. 1 digit 1 digit 1 alphanum. 2 digits (C) or 8 digits 9 alphanumerics
  2788. (0-4) (0-3) (0-9A-E) 6 digits (L) (1 of 6 patterns)
  2789. ---------------------------------------------------------------------------
  2790. Table: {#tbl:mailmark_4s_input_fields
  2791. tag=": Royal Mail 4-State Mailmark Input Fields"}
  2792. The 6 Destination+DPS (Destination Post Code plus Delivery Point Suffix)
  2793. patterns are:
  2794. ----------- ----------- -----------
  2795. `FNFNLLNLS` `FFNNLLNLS` `FFNNNLLNL`
  2796. `FFNFNLLNL` `FNNLLNLSS` `FNNNLLNLS`
  2797. ----------- ----------- -----------
  2798. Table: {#tbl:mailmark_destination_dps
  2799. tag=": Royal Mail Mailmark Destination+DPS Patterns"}
  2800. where `'F'` stands for full alphabetic (A-Z), `'L'` for limited alphabetic (A-Z
  2801. less `'CIKMOV'`), `'N'` for numeric (0-9), and `'S'` for space.
  2802. Four of the permitted patterns include a number of trailing space characters -
  2803. these will be appended by Zint if not included in the input data.
  2804. For the two-dimensional Data Matrix-based version, see [6.6.2 Royal Mail 2D
  2805. Mailmark (CMDM) (Data Matrix)].
  2806. ### 6.5.5 USPS Intelligent Mail
  2807. ![`zint -b USPS_IMAIL --compliantheight -d
  2808. "01234567094987654321-01234"`](images/usps_imail.svg){.trk}
  2809. Also known as the OneCode barcode and used in the U.S. by the United States
  2810. Postal Service (USPS), the Intelligent Mail system replaced the POSTNET and
  2811. PLANET symbologies in 2009. Intelligent Mail is a fixed length (65-bar) symbol
  2812. which combines routing and customer information in a single symbol. Input data
  2813. consists of a 20-digit tracking code, followed by a dash (`-`), followed by a
  2814. delivery point zip-code which can be 0, 5, 9 or 11 digits in length. For example
  2815. all of the following inputs are valid data entries:
  2816. - `"01234567094987654321"`
  2817. - `"01234567094987654321-01234"`
  2818. - `"01234567094987654321-012345678"`
  2819. - `"01234567094987654321-01234567891"`
  2820. ### 6.5.6 Japanese Postal Code
  2821. ![`zint -b JAPANPOST --compliantheight -d
  2822. "15400233-16-4-205"`](images/japanpost.svg){.trk}
  2823. Used for address data on mail items for Japan Post. Accepted values are 0-9,
  2824. A-Z and dash (`-`). A modulo 19 check digit is added by Zint.
  2825. ### 6.5.7 DAFT Code
  2826. ![`zint -b DAFT -d "AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF" --height=8.494
  2827. --vers=256`](images/daft_rm4scc.svg){.trk}
  2828. This is a method for creating 4-state codes where the data encoding is provided
  2829. by an external program. Input data should consist of the letters `'D'`, `'A'`,
  2830. `'F'` and `'T'` where these refer to descender, ascender, full (ascender and
  2831. descender) and tracker (neither ascender nor descender) respectively. All other
  2832. characters are invalid. The ratio of the tracker size to full height can be
  2833. given in thousandths (permille) using the `--vers` option (API `option_2`). The
  2834. default value is 250 (25%).
  2835. For example the following
  2836. ```bash
  2837. zint -b DAFT -d AAFDTTDAFADTFTTFFFDATFTADTTFFTDAFAFDTF --height=8.494 --vers=256
  2838. ```
  2839. produces the same barcode (see [6.5.3 Royal Mail 4-State Customer Code
  2840. (RM4SCC)]) as
  2841. ```bash
  2842. zint -b RM4SCC --compliantheight -d "W1J0TR01"
  2843. ```
  2844. \clearpage
  2845. ## 6.6 Matrix Symbols
  2846. ### 6.6.1 Data Matrix (ISO 16022)
  2847. ![`zint -b HIBC_DM -d "/ACMRN123456/V200912190833" --fast
  2848. --square`](images/hibc_dm.svg){.i2dbig}
  2849. Also known as Semacode this symbology was developed in 1989 by Acuity CiMatrix
  2850. in partnership with the U.S. DoD and NASA. The symbol can encode a large amount
  2851. of data in a small area. Data Matrix encodes characters in the Latin-1 set by
  2852. default but also supports encoding in other character sets using the ECI
  2853. mechanism. It can also encode GS1 data. The size of the generated symbol can be
  2854. adjusted using the `--vers` option (API `option_2`) as shown in the table below.
  2855. A separate symbology ID (`BARCODE_HIBC_DM`) can be used to encode Health
  2856. Industry Barcode (HIBC) data. Note that only ECC200 encoding is supported, the
  2857. older standards have now been removed from Zint.
  2858. Input Symbol Size Input Symbol Size Input Symbol Size
  2859. ----- ----------- -- ----- ----------- -- ----- -----------
  2860. 1 10 x 10 11 36 x 36 21 104 x 104
  2861. 2 12 x 12 12 40 x 40 22 120 x 120
  2862. 3 14 x 14 13 44 x 44 23 132 x 132
  2863. 4 16 x 16 14 48 x 48 24 144 x 144
  2864. 5 18 x 18 15 52 x 52 25 8 x 18
  2865. 6 20 x 20 16 64 x 64 26 8 x 32
  2866. 7 22 x 22 17 72 x 72 28 12 x 26
  2867. 8 24 x 24 18 80 x 80 28 12 x 36
  2868. 9 26 x 26 19 88 x 88 29 16 x 36
  2869. 10 32 x 32 20 96 x 96 30 16 x 48
  2870. Table: {#tbl:datamatrix_sizes tag=": Data Matrix Sizes"}
  2871. The largest version 24 (144 x 144) can encode 3116 digits, around 2335
  2872. alphanumeric characters, or 1555 bytes of data.
  2873. When using automatic symbol sizes you can force Zint to use square symbols
  2874. (versions 1-24) at the command line by using the option `--square` (API
  2875. `option_3 = DM_SQUARE`).
  2876. Data Matrix Rectangular Extension (ISO/IEC 21471) codes may be generated with
  2877. the following values as before:
  2878. Input Symbol Size Input Symbol Size
  2879. ----- ----------- -- ----- -----------
  2880. 31 8 x 48 40 20 x 36
  2881. 32 8 x 64 41 20 x 44
  2882. 33 8 x 80 42 20 x 64
  2883. 34 8 x 96 43 22 x 48
  2884. 35 8 x 120 44 24 x 48
  2885. 36 8 x 144 45 24 x 64
  2886. 37 12 x 64 46 26 x 40
  2887. 38 12 x 88 47 26 x 48
  2888. 39 16 x 64 48 26 x 64
  2889. Table: {#tbl:dmre_sizes tag=": DMRE Sizes"}
  2890. DMRE symbol sizes may be activated in automatic size mode using the option
  2891. `--dmre` (API `option_3 = DM_DMRE`).
  2892. GS1 data may be encoded using FNC1 (default) or GS (Group Separator, ASCII 29)
  2893. as separator. Use the option `--gssep` to change to GS (API `output_options |=
  2894. GS1_GS_SEPARATOR`).
  2895. By default Zint uses a "de facto" codeword placement for symbols of size 144 x
  2896. 144 (version 24). To override this and use the now clarified ISO/IEC standard
  2897. placement, use option `--dmiso144` (API `option_3 |= DM_ISO_144`).
  2898. For a faster but less optimal encoding, the `--fast` option (API `input_mode |=
  2899. FAST_MODE`) may be used.
  2900. Data Matrix supports Structured Append of up to 16 symbols and a numeric ID
  2901. (file identifications), which can be set by using the `--structapp` option (see
  2902. [4.17 Structured Append]) (API `structapp`). The ID consists of 2 numbers `ID1`
  2903. and `ID2`, each of which can range from 1 to 254, and is specified as the single
  2904. number `ID1 * 1000 + ID2`, so for instance `ID1` `"123"` and `ID2` `"234"` would
  2905. be given as `"123234"`. Note that both `ID1` and `ID2` must be non-zero, so e.g.
  2906. `"123000"` or `"000123"` would be invalid IDs. If an ID is not given it defaults
  2907. to `"001001"`.
  2908. ### 6.6.2 Royal Mail 2D Mailmark (CMDM) (Data Matrix)
  2909. ![`zint -b MAILMARK_2D -d "JGB 01Z999999900000001EC1A1AA1A0SN35TQ"
  2910. --vers=30`](images/mailmark_2d.svg){.i2dbig}
  2911. This variant of Data Matrix, also known as "Complex Mail Data Mark" (CMDM), was
  2912. introduced by Royal Mail along with [6.5.4 Royal Mail 4-State Mailmark], and
  2913. offers space for customer data following an initial pre-formatted 45 character
  2914. section, as summarized below.
  2915. Field Name Length Values
  2916. ---------------- ----------- ------------------------------
  2917. UPU Country ID 4 `"JGB "`
  2918. Information Type 1 Alphanumeric
  2919. Version ID 1 `"1"`
  2920. Class 1 Alphanumeric
  2921. Supply Chain ID 7 Numeric
  2922. Item ID 8 Numeric
  2923. Destination+DPS 9 Alphanumeric (1 of 6 patterns)
  2924. Service Type 1 Numeric
  2925. RTS Post Code 7 Alphanumeric (1 of 6 patterns)
  2926. Reserved 6 Spaces
  2927. Customer Data 6, 45 or 29 Anything (Latin-1)
  2928. Table: {#tbl:mailmark_2d_input_fields
  2929. tag=": Royal Mail 2D Mailmark Input Fields"}
  2930. The 6 Destination+DPS (Destination Post Code plus Delivery Point Suffix)
  2931. patterns are the same as for the 4-state - see Table
  2932. {@tbl:mailmark_destination_dps}. The 6 RTS (Return to Sender) Post Code patterns
  2933. are the same also except without the additional DPS `'NL'`, i.e.
  2934. --------- --------- ---------
  2935. `FNFNLLS` `FFNNLLS` `FFNNNLL`
  2936. `FFNFNLL` `FNNLLSS` `FNNNLLS`
  2937. --------- --------- ---------
  2938. Table: {#tbl:mailmark_2d_rts
  2939. tag=": Royal Mail 2D Mailmark RTS Patterns"}
  2940. where `'F'` is full alphabetic (A-Z), `'L'` limited alphabetic (A-Z less
  2941. `'CIKMOV'`), `'N'` numeric (0-9), and `'S'` space.
  2942. Three sizes are defined, one rectangular, with varying maximum amounts of
  2943. optional customer data:
  2944. Name Size Customer Data Zint Version
  2945. ------- ------- ------------- ------------
  2946. Type 7 24 x 24 6 characters 8
  2947. Type 9 32 x 32 45 characters 10
  2948. Type 29 16 x 48 29 characters 30
  2949. Table: {#tbl:mailmark_2d_sizes tag=": Royal Mail 2D Mailmark Sizes"}
  2950. Zint will automatically select a size based on the amount of customer data, or
  2951. it can be specified using the `--vers` option (API `option_2`), which takes the
  2952. Zint version number (one more than the Royal Mail Type number). Zint will prefix
  2953. the input data with `"JGB "` if it's missing, and also space-pad the input if
  2954. the customer data is absent or falls short. As with Data Matrix, the rectangular
  2955. symbol Type 29 can be excluded from automatic size selection by using the option
  2956. `--square` (API `option_3 = DM_SQUARE`).
  2957. GS1 data, the ECI mechanism, and Structured Append are not supported.
  2958. ### 6.6.3 QR Code (ISO 18004)
  2959. ![`zint -b QRCODE -d "QR Code Symbol" --mask=5`](images/qrcode.svg){.i2dbig}
  2960. Also known as Quick Response Code this symbology was developed by Denso. Four
  2961. levels of error correction are available using the `--secure` option (API
  2962. `option_1`) as shown in the following table.
  2963. Input ECC Level Error Correction Capacity Recovery Capacity
  2964. ----- --------- ------------------------- -----------------
  2965. 1 L Approx 20% of symbol Approx 7%
  2966. 2 M Approx 37% of symbol Approx 15%
  2967. 3 Q Approx 55% of symbol Approx 25%
  2968. 4 H Approx 65% of symbol Approx 30%
  2969. Table: {#tbl:qrcode_eccs tag=": QR Code ECC Levels"}
  2970. The size of the symbol can be specified by setting the `--vers` option (API
  2971. `option_2`) to the QR Code version required (1-40). The size of symbol generated
  2972. is shown in the table below.
  2973. Input Symbol Size Input Symbol Size Input Symbol Size
  2974. ----- ----------- -- ----- ----------- -- ----- -----------
  2975. 1 21 x 21 15 77 x 77 29 133 x 133
  2976. 2 25 x 25 16 81 x 81 30 137 x 137
  2977. 3 29 x 29 17 85 x 85 31 141 x 141
  2978. 4 33 x 33 18 89 x 89 32 145 x 145
  2979. 5 37 x 37 19 93 x 93 33 149 x 149
  2980. 6 41 x 41 20 97 x 97 34 153 x 153
  2981. 7 45 x 45 21 101 x 101 35 157 x 157
  2982. 8 49 x 49 22 105 x 105 36 161 x 161
  2983. 9 53 x 53 23 109 x 109 37 165 x 165
  2984. 10 57 x 57 24 113 x 113 38 169 x 169
  2985. 11 61 x 61 25 117 x 117 39 173 x 173
  2986. 12 65 x 65 26 121 x 121 40 177 x 177
  2987. 13 69 x 69 27 125 x 125
  2988. 14 73 x 73 28 129 x 129
  2989. Table: {#tbl:qrcode_sizes tag=": QR Code Sizes"}
  2990. The maximum capacity of a QR Code symbol (version 40) is 7089 numeric digits,
  2991. 4296 alphanumeric characters or 2953 bytes of data. QR Code symbols can also be
  2992. used to encode GS1 data. QR Code symbols can by default encode either characters
  2993. in the Latin-1 set or Kanji, Katakana and ASCII characters which are members of
  2994. the Shift JIS encoding scheme. In addition QR Code supports other character sets
  2995. using the ECI mechanism. Input should usually be entered as UTF-8 with
  2996. conversion to Latin-1 or Shift JIS being carried out by Zint. A separate
  2997. symbology ID (`BARCODE_HIBC_QR`) can be used to encode Health Industry Barcode
  2998. (HIBC) data.
  2999. Non-ASCII data density may be maximized by using the `--fullmultibyte` switch
  3000. (API `option_3 = ZINT_FULL_MULTIBYTE`), but check that your barcode reader
  3001. supports this before using.
  3002. QR Code has eight different masks designed to minimize unwanted patterns. The
  3003. best mask to use is selected automatically by Zint but may be manually specified
  3004. by using the `--mask` switch with values 0-7, or in the API by setting
  3005. `option_3 = (N + 1) << 8` where N is 0-7. To use with `ZINT_FULL_MULTIBYTE` set
  3006. ```c
  3007. option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8
  3008. ```
  3009. The `--fast` option (API `input_mode |= FAST_MODE`) may be used when leaving
  3010. Zint to automatically select a mask to reduce the number of masks to try to four
  3011. (0, 2, 4, 7).
  3012. QR Code supports Structured Append of up to 16 symbols and a numeric ID
  3013. (parity), which can be set by using the `--structapp` option (see [4.17
  3014. Structured Append]) (API `structapp`). The parity ID ranges from 0 (default) to
  3015. 255, and for full compliance should be set to the value obtained by `XOR`-ing
  3016. together each byte of the complete data forming the sequence. Currently this
  3017. calculation must be done outside of Zint.
  3018. ### 6.6.4 Micro QR Code (ISO 18004)
  3019. ![`zint -b MICROQR -d "01234567"`](images/microqr.svg){.i2dbig}
  3020. A miniature version of the QR Code symbol for short messages, Micro QR Code
  3021. symbols can encode either Latin-1 characters or Shift JIS characters. Input
  3022. should be entered as a UTF-8 stream with conversion to Latin-1 or Shift JIS
  3023. being carried out automatically by Zint. A preferred symbol size can be selected
  3024. by using the `--vers` option (API `option_2`), as shown in the table below. Note
  3025. that versions M1 and M2 have restrictions on what characters can be encoded.
  3026. ------------------------------------------------------------------
  3027. Input Version Symbol Size Allowed Characters
  3028. ----- ------- ----------- ----------------------------------
  3029. 1 M1 11 x 11 Numeric only
  3030. 2 M2 13 x 13 Numeric, uppercase letters, space,
  3031. and the characters `"$%*+-./:"`
  3032. 3 M3 15 x 15 Latin-1 and Shift JIS
  3033. 4 M4 17 x 17 Latin-1 and Shift JIS
  3034. ------------------------------------------------------------------
  3035. Table: {#tbl:micrqr_sizes tag=": Micro QR Code Sizes"}
  3036. Version M4 can encode up to 35 digits, 21 alphanumerics, 15 bytes or 9 Kanji
  3037. characters.
  3038. Except for version M1, which is always ECC level L, the amount of ECC codewords
  3039. can be adjusted using the `--secure` option (API `option_1`); however ECC level
  3040. H is not available for any version, and ECC level Q is only available for
  3041. version M4:
  3042. ----------------------------------------------------------------------
  3043. Input ECC Error Correction Recovery Available for
  3044. Level Capacity Capacity Versions
  3045. ----- ----- -------------------- ---------- --------------
  3046. 1 L Approx 20% of symbol Approx 7% M1, M2, M3, M4
  3047. 2 M Approx 37% of symbol Approx 15% M2, M3, M4
  3048. 3 Q Approx 55% of symbol Approx 25% M4
  3049. ----------------------------------------------------------------------
  3050. Table: {#tbl:micrqr_eccs tag=": Micro QR ECC Levels"}
  3051. The defaults for symbol size and ECC level depend on the input and whether
  3052. either of them is specified.
  3053. For barcode readers that support it, non-ASCII data density may be maximized by
  3054. using the `--fullmultibyte` switch (API `option_3 = ZINT_FULL_MULTIBYTE`).
  3055. Micro QR Code has four different masks designed to minimize unwanted patterns.
  3056. The best mask to use is selected automatically by Zint but may be manually
  3057. specified by using the `--mask` switch with values 0-3, or in the API by setting
  3058. `option_3 = (N + 1) << 8` where N is 0-3. To use with `ZINT_FULL_MULTIBYTE` set
  3059. ```c
  3060. option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8
  3061. ```
  3062. ### 6.6.5 Rectangular Micro QR Code (rMQR) (ISO 23941)
  3063. ![`zint -b RMQR -d "0123456"`](images/rmqr.svg){.i2dbig}
  3064. A rectangular version of QR Code, rMQR supports encoding of GS1 data, and either
  3065. Latin-1 characters or Shift JIS characters, and other encodings using the ECI
  3066. mechanism. As with other symbologies data should be entered as UTF-8 with
  3067. conversion being handled by Zint. The amount of ECC codewords can be adjusted
  3068. using the `--secure` option (API `option_1`), however only ECC levels M and H
  3069. are valid for this type of symbol.
  3070. Input ECC Level Error Correction Capacity Recovery Capacity
  3071. ----- --------- ------------------------- -----------------
  3072. 2 M Approx 37% of symbol Approx 15%
  3073. 4 H Approx 65% of symbol Approx 30%
  3074. Table: {#tbl:rmqr_eccs tag=": rMQR ECC Levels"}
  3075. The preferred symbol sizes can be selected using the `--vers` option (API
  3076. `option_2`) as shown in the table below. Input values between 33 and 38 fix the
  3077. height of the symbol while allowing Zint to determine the minimum symbol width.
  3078. --------------------------------------------------------------------------
  3079. Input Version Symbol Size (HxW) Input Version Symbol Size (HxW)
  3080. ----- ------- ----------------- - ----- ------- --------------------
  3081. 1 R7x43 7 x 43 20 R13x77 13 x 77
  3082. 2 R7x59 7 x 59 21 R13x99 13 x 99
  3083. 3 R7x77 7 x 77 22 R13x139 13 x 139
  3084. 4 R7x99 7 x 99 23 R15x43 15 x 43
  3085. 5 R7x139 7 x 139 24 R15x59 15 x 59
  3086. 6 R9x43 9 x 43 25 R15x77 15 x 77
  3087. 7 R9x59 9 x 59 26 R15x99 15 x 99
  3088. 8 R9x77 9 x 77 27 R15x139 15 x 139
  3089. 9 R9x99 9 x 99 28 R17x43 17 x 43
  3090. 10 R9x139 9 x 139 29 R17x59 17 x 59
  3091. 11 R11x27 11 x 27 30 R17x77 17 x 77
  3092. 12 R11x43 11 x 43 31 R17x99 17 x 99
  3093. 13 R11x59 11 x 59 32 R17x139 17 x 139
  3094. 14 R11x77 11 x 77 33 R7xW 7 x automatic width
  3095. 15 R11x99 11 x 99 34 R9xW 9 x automatic width
  3096. 16 R11x139 11 x 139 35 R11xW 11 x automatic width
  3097. 17 R13x27 13 x 27 36 R13xW 13 x automatic width
  3098. 18 R13x43 13 x 43 37 R15xW 15 x automatic width
  3099. 19 R13x59 13 x 59 38 R17xW 17 x automatic width
  3100. --------------------------------------------------------------------------
  3101. Table: {#tbl:rmqr_sizes tag=": rMQR Sizes"}
  3102. The largest version R17x139 (32) can encode up to 361 digits, 219 alphanumerics,
  3103. 150 bytes, or 92 Kanji characters.
  3104. For barcode readers that support it, non-ASCII data density may be maximized by
  3105. using the `--fullmultibyte` switch or in the API by setting
  3106. `option_3 = ZINT_FULL_MULTIBYTE`.
  3107. ### 6.6.6 UPNQR (Univerzalnega Plačilnega Naloga QR)
  3108. ![`zint -b UPNQR -i upn_utf8.txt --quietzones`](images/upnqr.svg){.i2d}
  3109. A variation of QR Code used by Združenje Bank Slovenije (Bank Association of
  3110. Slovenia). The size, error correction level and ECI are set by Zint and do not
  3111. need to be specified. UPNQR is unusual in that it uses Latin-2 (ISO/IEC 8859-2
  3112. plus ASCII) formatted data. Zint will accept UTF-8 data and convert it to
  3113. Latin-2, or if your data is already Latin-2 formatted use the `--binary` switch
  3114. (API `input_mode = DATA_MODE`).
  3115. The following example creates a symbol from data saved as a Latin-2 file:
  3116. ```bash
  3117. zint -o upnqr.png -b 143 --scale=3 --binary -i upn.txt
  3118. ```
  3119. A mask may be manually specified or the `--fast` option used as with QRCODE.
  3120. ### 6.6.7 MaxiCode (ISO 16023)
  3121. ![`zint -b MAXICODE -d "1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN
  3122. ST\GNY\GNY\R\E" --esc --primary="152382802000000"
  3123. --scmvv=96`](images/maxicode.svg){.i2d}
  3124. Developed by UPS the MaxiCode symbology employs a grid of hexagons surrounding a
  3125. bullseye finder pattern. This symbology is designed for the identification of
  3126. parcels. MaxiCode symbols can be encoded in one of five modes. In modes 2 and 3
  3127. MaxiCode symbols are composed of two parts named the primary and secondary
  3128. messages. The primary message consists of a Structured Carrier Message which
  3129. includes various data about the package being sent and the secondary message
  3130. usually consists of address data in a data structure. The format of the primary
  3131. message required by Zint is given in the following table.
  3132. Characters Meaning
  3133. ---------- ---------------------------------------------------------------
  3134. 1 - 9 Postcode data which can consist of up to 9 digits (for mode 2)
  3135. or up to 6 alphanumeric characters (for mode 3). Remaining
  3136. unused characters for mode 3 can be filled with the SPACE
  3137. character (ASCII 32) or omitted.
  3138. (adjust the following character positions according to postcode
  3139. length)
  3140. 10 - 12 Three-digit country code according to ISO 3166-1.
  3141. 13 - 15 Three-digit service code. This depends on your parcel courier.
  3142. Table: {#tbl:maxicode_scm tag=": MaxiCode Structured Carrier Message Format"}
  3143. The primary message can be set at the command prompt using the `--primary`
  3144. switch (API `primary`). The secondary message uses the normal data entry method.
  3145. For example:
  3146. ```bash
  3147. zint -o test.eps -b 57 --primary="999999999840012" \
  3148. -d "Secondary Message Here"
  3149. ```
  3150. When using the API the primary message must be placed in the `primary` string.
  3151. The secondary is entered in the same way as described in [5.2 Encoding and
  3152. Saving to File]. When either of these modes is selected Zint will analyse the
  3153. primary message and select either mode 2 or mode 3 as appropriate.
  3154. As a convenience the secondary message for modes 2 and 3 can be set to be
  3155. prefixed by the ISO/IEC 15434 Format `"01"` (transportation) sequence
  3156. `"[)>\R01\Gvv"`, where `vv` is a 2-digit version, by using the `--scmvv` switch
  3157. (API `option_2 = vv + 1`). For example to use the common version `"96"` (ASC
  3158. MH10/SC 8):
  3159. ```bash
  3160. zint -b 57 --primary="152382802840001" --scmvv=96 --esc -d \
  3161. "1Z00004951\GUPSN\G06X610\G159\G1234567\G1/1\G\GY\G1 MAIN ST\GNY\GNY\R\E"
  3162. ```
  3163. will prefix `"[)>\R01\G96"` to the secondary message. (`\R`, `\G` and `\E` are
  3164. the escape sequences for Record Separator, Group Separator and End of
  3165. Transmission respectively - see Table {@tbl:escape_sequences}.)
  3166. Modes 4 to 6 can be accessed using the `--mode` switch (API `option_1`). Modes 4
  3167. to 6 do not have a primary message. For example:
  3168. ```bash
  3169. zint -o test.eps -b 57 --mode=4 -d "A MaxiCode Message in Mode 4"
  3170. ```
  3171. Mode 6 is reserved for the maintenance of scanner hardware and should not be
  3172. used to encode user data.
  3173. This symbology uses Latin-1 character encoding by default but also supports the
  3174. ECI encoding mechanism. The maximum length of text which can be placed in a
  3175. MaxiCode symbol depends on the type of characters used in the text.
  3176. Example maximum data lengths are given in the table below:
  3177. -----------------------------------------------------------------------
  3178. Mode Maximum Data Length Maximum Data Length Number of Error
  3179. for Capital Letters for Numeric Digits Correction Codewords
  3180. ---- ------------------- ------------------- --------------------
  3181. 2`*` 84 126 50
  3182. 3`*` 84 126 50
  3183. 4 93 138 50
  3184. 5 77 113 66
  3185. 6 93 138 50
  3186. -----------------------------------------------------------------------
  3187. Table: {#tbl:maxicode_data_length_maxima tag=": MaxiCode Data Length Maxima"}
  3188. `*` - secondary only
  3189. MaxiCode supports Structured Append of up to 8 symbols, which can be set by
  3190. using the `--structapp` option (see [4.17 Structured Append]) (API `structapp`).
  3191. It does not support specifying an ID.
  3192. MaxiCode uses a different scaling than other symbols for raster output, see
  3193. [4.9.3 MaxiCode Raster Scaling], and also for EMF vector output, when the scale
  3194. is multiplied by 20 instead of 2.
  3195. ### 6.6.8 Aztec Code (ISO 24778)
  3196. ![`zint -b AZTEC -d "123456789012"`](images/aztec.svg){.i2d}
  3197. Invented by Andrew Longacre at Welch Allyn Inc in 1995 the Aztec Code symbol is
  3198. a matrix symbol with a distinctive bullseye finder pattern. Zint can generate
  3199. Compact Aztec Code (sometimes called Small Aztec Code) as well as 'full-range'
  3200. Aztec Code symbols and by default will automatically select symbol type and size
  3201. dependent on the length of the data to be encoded. Error correction codewords
  3202. will normally be generated to fill at least 23% of the symbol. Two options are
  3203. available to change this behaviour:
  3204. The size of the symbol can be specified using the `--vers` option (API
  3205. `option_2`) to a value between 1 and 36 according to the following table. The
  3206. symbols marked with an asterisk (`*`) in the table below are 'compact' symbols,
  3207. meaning they have a smaller bullseye pattern at the centre of the symbol.
  3208. Input Symbol Size Input Symbol Size Input Symbol Size
  3209. ----- ----------- -- ----- ----------- -- ----- -----------
  3210. 1 15 x 15`*` 13 53 x 53 25 105 x 105
  3211. 2 19 x 19`*` 14 57 x 57 26 109 x 109
  3212. 3 23 x 23`*` 15 61 x 61 27 113 x 113
  3213. 4 27 x 27`*` 16 67 x 67 28 117 x 117
  3214. 5 19 x 19 17 71 x 71 29 121 x 121
  3215. 6 23 x 23 18 75 x 75 30 125 x 125
  3216. 7 27 x 27 19 79 x 79 31 131 x 131
  3217. 8 31 x 31 20 83 x 83 32 135 x 135
  3218. 9 37 x 37 21 87 x 87 33 139 x 139
  3219. 10 41 x 41 22 91 x 91 34 143 x 143
  3220. 11 45 x 45 23 95 x 95 35 147 x 147
  3221. 12 49 x 49 24 101 x 101 36 151 x 151
  3222. Table: {#tbl:aztec_sizes tag=": Aztec Code Sizes"}
  3223. Note that in symbols which have a specified size the amount of error correction
  3224. is dependent on the length of the data input and Zint will allow error
  3225. correction capacities as low as 3 codewords.
  3226. Alternatively the amount of error correction data can be specified by setting
  3227. the `--secure` option (API `option_1`) to a value from the following table.
  3228. Mode Error Correction Capacity
  3229. ---- -------------------------
  3230. 1 >10% + 3 codewords
  3231. 2 >23% + 3 codewords
  3232. 3 >36% + 3 codewords
  3233. 4 >50% + 3 codewords
  3234. Table: {#tbl:aztec_eccs tag=": Aztec Code Error Correction Modes"}
  3235. It is not possible to select both symbol size and error correction capacity for
  3236. the same symbol. If both options are selected then the error correction capacity
  3237. selection will be ignored.
  3238. Aztec Code supports ECI encoding and can encode up to a maximum length of
  3239. approximately 3823 numeric or 3067 alphabetic characters or 1914 bytes of data.
  3240. A separate symbology ID (`BARCODE_HIBC_AZTEC`) can be used to encode Health
  3241. Industry Barcode (HIBC) data.
  3242. Aztec Code supports Structured Append of up to 26 symbols and an optional
  3243. alphanumeric ID of up to 32 characters, which can be set by using the
  3244. `--structapp` option (see [4.17 Structured Append]) (API `structapp`). The ID
  3245. cannot contain spaces. If an ID is not given, no ID is encoded.
  3246. ### 6.6.9 Aztec Runes (ISO 24778)
  3247. ![`zint -b AZRUNE -d "125"`](images/azrune.svg){.i2d}
  3248. A truncated version of compact Aztec Code for encoding whole integers between 0
  3249. and 255, as defined in ISO/IEC 24778 Annex A. Includes Reed-Solomon error
  3250. correction. It does not support Structured Append.
  3251. ### 6.6.10 Code One
  3252. ![`zint -b CODEONE -d "1234567890123456789012"`](images/codeone.svg){.i2d}
  3253. A matrix symbology developed by Ted Williams in 1992 which encodes data in a way
  3254. similar to Data Matrix, Code One is able to encode the Latin-1 character set or
  3255. GS1 data, and also supports the ECI mechanism. There are two types of Code One
  3256. symbol - fixed-ratio symbols which are roughly square (versions A through to H)
  3257. and variable-width versions (versions S and T). These can be selected by using
  3258. `--vers` (API `option_2`) as shown in the table below:
  3259. ------------------------------------------------------------
  3260. Input Version Size Numeric Alphanumeric
  3261. (W x H) Data Capacity Data Capacity
  3262. ----- ------- ---------- ------------- -------------
  3263. 1 A 16 x 18 22 13
  3264. 2 B 22 x 22 44 27
  3265. 3 C 28 x 28 104 64
  3266. 4 D 40 x 42 217 135
  3267. 5 E 52 x 54 435 271
  3268. 6 F 70 x 76 886 553
  3269. 7 G 104 x 98 1755 1096
  3270. 8 H 148 x 134 3550 2218
  3271. 9 S width x 8 18 N/A
  3272. 10 T width x 16 90 55
  3273. ------------------------------------------------------------
  3274. Table: {#tbl:codeone_sizes tag=": Code One Sizes"}
  3275. Version S symbols can only encode numeric data. The width of version S and
  3276. version T symbols is determined by the length of the input data.
  3277. Code One supports Structured Append of up to 128 symbols, which can be set by
  3278. using the `--structapp` option (see [4.17 Structured Append]) (API `structapp`).
  3279. It does not support specifying an ID. Structured Append is not supported with
  3280. GS1 data nor for Version S symbols.
  3281. ### 6.6.11 Grid Matrix
  3282. ![`zint -b GRIDMATRIX --eci=29 -d "AAT2556 电池充电器+降压转换器
  3283. 200mA至2A tel:86 019 82512738"`](images/gridmatrix.svg){.i2d}
  3284. Grid Matrix groups modules in a chequerboard pattern, and by default supports
  3285. the GB 2312 standard set, which includes Hanzi, ASCII and a small number of
  3286. ISO/IEC 8859-1 characters. Input should be entered as UTF-8 with conversion to
  3287. GB 2312 being carried out automatically by Zint. Up to around 1529 alphanumeric
  3288. characters or 2751 digits may be encoded. The symbology also supports the ECI
  3289. mechanism. Support for GS1 data has not yet been implemented.
  3290. The size of the symbol and the error correction capacity can be specified. If
  3291. you specify both of these values then Zint will make a 'best-fit' attempt to
  3292. satisfy both conditions. The symbol size can be specified using the `--vers`
  3293. option (API `option_2`), and the error correction capacity can be specified by
  3294. using the `--secure` option (API `option_1`), according to the following tables.
  3295. Input Symbol Size Input Symbol Size
  3296. ----- ----------- - ----- -----------
  3297. 1 18 x 18 8 102 x 102
  3298. 2 30 x 30 9 114 x 114
  3299. 3 42 x 42 10 126 x 126
  3300. 4 54 x 54 11 138 x 138
  3301. 5 66 x 66 12 150 x 150
  3302. 6 78 x 78 13 162 x 162
  3303. 7 90 x 90
  3304. Table: {#tbl:gridmatrix_sizes tag=": Grid Matrix Sizes"}
  3305. Mode Error Correction Capacity
  3306. ---- -------------------------
  3307. 1 Approximately 10%
  3308. 2 Approximately 20%
  3309. 3 Approximately 30%
  3310. 4 Approximately 40%
  3311. 5 Approximately 50%
  3312. Table: {#tbl:gridmatrix_eccs tag=": Grid Matrix Error Correction Modes"}
  3313. Non-ASCII data density may be maximized by using the `--fullmultibyte` switch
  3314. (API `option_3 = ZINT_FULL_MULTIBYTE`), but check that your barcode reader
  3315. supports this before using.
  3316. Grid Matrix supports Structured Append of up to 16 symbols and a numeric ID
  3317. (file signature), which can be set by using the `--structapp` option (see [4.17
  3318. Structured Append]) (API `structapp`). The ID ranges from 0 (default) to 255.
  3319. ### 6.6.12 DotCode
  3320. ![`zint -b DOTCODE -d "[01]00012345678905[17]201231[10]ABC123456"
  3321. --gs1`](images/dotcode.svg){.i2d}
  3322. DotCode uses a grid of dots in a rectangular formation to encode characters up
  3323. to a maximum of approximately 450 characters (or 900 numeric digits). The
  3324. symbology supports ECI encoding and GS1 data encoding. By default Zint will
  3325. produce a symbol which is approximately square, however the width of the symbol
  3326. can be adjusted by using the `--cols` option (API `option_2`) (maximum 200).
  3327. Outputting DotCode to raster images (BMP, GIF, PCX, PNG, TIF) will require
  3328. setting the scale of the image to a larger value than the default (e.g.
  3329. approximately 10) for the dots to be plotted correctly. Approximately 33% of the
  3330. resulting symbol is comprised of error correction codewords.
  3331. DotCode has two sets of 4 masks, designated 0-3 and 0'-3', the second `"prime"`
  3332. set being the same as the first with corners lit. The best mask to use is
  3333. selected automatically by Zint but may be manually specified by using the
  3334. `--mask` switch with values 0-7, where 4-7 denote 0'-3', or in the API by
  3335. setting `option_3 = (N + 1) << 8` where N is 0-7.
  3336. DotCode supports Structured Append of up to 35 symbols, which can be set by
  3337. using the `--structapp` option (see [4.17 Structured Append]) (API `structapp`).
  3338. It does not support specifying an ID.
  3339. ### 6.6.13 Han Xin Code (ISO 20830)
  3340. ![`zint -b HANXIN -d "Hanxin Code symbol"`](images/hanxin.svg){.i2d}
  3341. Also known as Chinese Sensible Code, Han Xin is capable of encoding characters
  3342. in either the Latin-1 character set or the GB 18030 character set (which is a
  3343. UTF, i.e. includes all Unicode characters, optimized for Chinese characters) and
  3344. is also able to support the ECI mechanism. Support for the encoding of GS1 data
  3345. has not yet been implemented.
  3346. The size of the symbol can be specified using the `--vers` option (API
  3347. `option_2`) to a value between 1 and 84 according to the following table.
  3348. Input Symbol Size Input Symbol Size Input Symbol Size
  3349. ----- ----------- -- ----- ----------- -- ----- -----------
  3350. 1 23 x 23 29 79 x 79 57 135 x 135
  3351. 2 25 x 25 30 81 x 81 58 137 x 137
  3352. 3 27 x 27 31 83 x 83 59 139 x 139
  3353. 4 29 x 29 32 85 x 85 60 141 x 141
  3354. 5 31 x 31 33 87 x 87 61 143 x 143
  3355. 6 33 x 33 34 89 x 89 62 145 x 145
  3356. 7 35 x 35 35 91 x 91 63 147 x 147
  3357. 8 37 x 37 36 93 x 93 64 149 x 149
  3358. 9 39 x 39 37 95 x 95 65 151 x 151
  3359. 10 41 x 41 38 97 x 97 66 153 x 153
  3360. 11 43 x 43 39 99 x 99 67 155 x 155
  3361. 12 45 x 45 40 101 x 101 68 157 x 157
  3362. 13 47 x 47 41 103 x 103 69 159 x 159
  3363. 14 49 x 49 42 105 x 105 70 161 x 161
  3364. 15 51 x 51 43 107 x 107 71 163 x 163
  3365. 16 53 x 53 44 109 x 109 72 165 x 165
  3366. 17 55 x 55 45 111 x 111 73 167 x 167
  3367. 18 57 x 57 46 113 x 113 74 169 x 169
  3368. 19 59 x 59 47 115 x 115 75 171 x 171
  3369. 20 61 x 61 48 117 x 117 76 173 x 173
  3370. 21 63 x 63 49 119 x 119 77 175 x 175
  3371. 22 65 x 65 50 121 x 121 78 177 x 177
  3372. 23 67 x 67 51 123 x 123 79 179 x 179
  3373. 24 69 x 69 52 125 x 125 80 181 x 181
  3374. 25 71 x 71 53 127 x 127 81 183 x 183
  3375. 26 73 x 73 54 129 x 129 82 185 x 185
  3376. 27 75 x 75 55 131 x 131 83 187 x 187
  3377. 28 77 x 77 56 133 x 133 84 189 x 189
  3378. Table: {#tbl:hanxin_sizes tag=": Han Xin Sizes"}
  3379. The largest version (84) can encode 7827 digits, 4350 ASCII characters, up to
  3380. 2175 Chinese characters, or 3261 bytes, making it the most capacious of all the
  3381. barcodes supported by Zint.
  3382. There are four levels of error correction capacity available for Han Xin Code
  3383. which can be set by using the `--secure` option (API `option_1`) to a value from
  3384. the following table.
  3385. Mode Recovery Capacity
  3386. ---- -----------------
  3387. 1 Approx 8%
  3388. 2 Approx 15%
  3389. 3 Approx 23%
  3390. 4 Approx 30%
  3391. Table: {#tbl:hanxin_eccs tag=": Han Xin Error Correction Modes"}
  3392. Non-ASCII data density may be maximized by using the `--fullmultibyte` switch
  3393. (API `option_3 = ZINT_FULL_MULTIBYTE`), but check that your barcode reader
  3394. supports this before using.
  3395. Han Xin has four different masks designed to minimize unwanted patterns. The
  3396. best mask to use is selected automatically by Zint but may be manually specified
  3397. by using the `--mask` switch with values 0-3, or in the API by setting
  3398. `option_3 = (N + 1) << 8` where N is 0-3. To use with `ZINT_FULL_MULTIBYTE` set
  3399. ```c
  3400. option_3 = ZINT_FULL_MULTIBYTE | (N + 1) << 8
  3401. ```
  3402. ### 6.6.14 Ultracode
  3403. ![`zint -b ULTRA -d
  3404. "HEIMASÍÐA KENNARAHÁSKÓLA ÍSLANDS"`](images/ultra.svg){.ultra}
  3405. This symbology uses a grid of coloured elements to encode data. ECI and GS1
  3406. modes are supported. The amount of error correction can be set using the
  3407. `--secure` option (API `option_1`) to a value as shown in the following table.
  3408. Value EC Level Amount of symbol holding error correction data
  3409. ----- -------- ----------------------------------------------
  3410. 1 EC0 0% - Error detection only
  3411. 2 EC1 Approx 5%
  3412. 3 EC2 Approx 9% - Default value
  3413. 4 EC3 Approx 17%
  3414. 5 EC4 Approx 25%
  3415. 6 EC5 Approx 33%
  3416. Table: {#tbl:ultra_eccs tag=": Ultracode Error Correction Values"}
  3417. Zint does not currently implement data compression by default, but this can be
  3418. initiated through the API by setting
  3419. ```c
  3420. symbol->option_3 = ULTRA_COMPRESSION;
  3421. ```
  3422. With compression, up to 504 digits, 375 alphanumerics or 252 bytes can be
  3423. encoded.
  3424. Revision 2 of Ultracode (2023) may be specified using `--vers=2` (API
  3425. `option_2 = 2`).
  3426. * * *
  3427. WARNING: Revision 2 of Ultracode was only finalized December 2023 and Zint has
  3428. not yet been updated to support it. Do not use.
  3429. * * *
  3430. Ultracode supports Structured Append of up to 8 symbols and an optional numeric
  3431. ID (File Number), which can be set by using the `--structapp` option (see [4.17
  3432. Structured Append]) (API `structapp`). The ID ranges from 1 to 80088. If an ID
  3433. is not given, no ID is encoded.
  3434. \clearpage
  3435. ## 6.7 Other Barcode-Like Markings
  3436. ### 6.7.1 Facing Identification Mark (FIM)
  3437. ![`zint -b FIM --compliantheight -d "C"`](images/fim.svg){.trk}
  3438. Used by the United States Postal Service (USPS), the FIM symbology is used to
  3439. assist automated mail processing. There are only 5 valid symbols which can be
  3440. generated using the characters A-E as shown in the table below.
  3441. Code Letter Usage
  3442. ----------- --------------------------------------------------------------
  3443. A Used for courtesy reply mail and metered reply mail with a
  3444. pre-printed POSTNET symbol.
  3445. B Used for business reply mail without a pre-printed zip code.
  3446. C Used for business reply mail with a pre-printed zip code.
  3447. D Used for Information Based Indicia (IBI) postage.
  3448. E Used for customized mail with a USPS Intelligent Mail barcode.
  3449. Table: {#tbl:fim_characters tag=": Valid FIM Characters"}
  3450. ### 6.7.2 Flattermarken
  3451. ![`zint -b FLAT -d "1304056"`](images/flat.svg){.lin}
  3452. Used for the recognition of page sequences in print-shops, the Flattermarken is
  3453. not a true barcode symbol and requires precise knowledge of the position of the
  3454. mark on the page. The Flattermarken system can encode numeric data up to a
  3455. maximum of 128 digits and does not include a check digit.
  3456. # 7. Legal and Version Information
  3457. ## 7.1 License
  3458. Zint, libzint and Zint Barcode Studio are Copyright © 2024 Robin Stuart. All
  3459. historical versions are distributed under the GNU General Public License version
  3460. 3 or later. Versions 2.5 and later are released under a dual license: the
  3461. encoding library is released under the BSD (3 clause) license whereas the GUI,
  3462. Zint Barcode Studio, and the CLI are released under the GNU General Public
  3463. License version 3 or later.
  3464. Telepen is a trademark of SB Electronic Systems Ltd.
  3465. QR Code is a registered trademark of Denso Wave Incorporated.
  3466. Mailmark is a registered trademark of Royal Mail Group Ltd.
  3467. Microsoft, Windows and the Windows logo are either registered trademarks or
  3468. trademarks of Microsoft Corporation in the United States and/or other countries.
  3469. Linux is the registered trademark of Linus Torvalds in the U.S. and other
  3470. countries.
  3471. Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other
  3472. countries.
  3473. The Zint logo is derived from "SF Planetary Orbiter" font by ShyFoundary.
  3474. Zint.org.uk website design and hosting provided by Robert Elliott.
  3475. ## 7.2 Patent Issues
  3476. All of the code in Zint is developed using information in the public domain,
  3477. usually freely available on the Internet. Some of the techniques used may be
  3478. subject to patents and other intellectual property legislation. It is my belief
  3479. that any patents involved in the technology underlying symbologies utilised by
  3480. Zint are 'unadopted', that is the holder does not object to their methods being
  3481. used.
  3482. Any methods patented or owned by third parties or trademarks or registered
  3483. trademarks used within Zint or in this document are and remain the property of
  3484. their respective owners and do not indicate endorsement or affiliation with
  3485. those owners, companies or organisations.
  3486. ## 7.3 Version Information
  3487. The current stable version of Zint is 2.13.0, released on 18th December 2023.
  3488. See `"ChangeLog"` in the project root directory for information on all releases.
  3489. ## 7.4 Sources of Information
  3490. Below is a list of some of the sources used in rough chronological order:
  3491. - Nick Johnson's Barcode Specifications
  3492. - Bar Code 1 Specification Source Page
  3493. - SB Electronic Systems Telepen website
  3494. - Pharmacode specifications from Laetus
  3495. - Morovia RM4SCC specification
  3496. - Australia Post's 'A Guide to Printing the 4-State Barcode' and bcsample source
  3497. code
  3498. - Plessey algorithm from GNU-Barcode v0.98 by Leonid A. Broukhis
  3499. - GS1 General Specifications v 8.0 Issue 2
  3500. - PNG: The Definitive Guide and wpng source code by Greg Reolofs
  3501. - PDF417 specification and pdf417 source code by Grand Zebu
  3502. - Barcode Reference, TBarCode/X User Documentation and TBarCode/X demonstration
  3503. program from Tec-It
  3504. - IEC16022 source code by Stefan Schmidt et al
  3505. - United States Postal Service Specification USPS-B-3200
  3506. - Adobe Systems Incorporated Encapsulated PostScript File Format Specification
  3507. - BSI Online Library
  3508. - Libdmtx Data Matrix ECC200 decoding library
  3509. ## 7.5 Standards Compliance
  3510. Zint was developed to provide compliance with the following British and
  3511. international standards:
  3512. ### 7.5.1 Symbology Standards
  3513. - ISO/IEC 24778:2008 Information technology - Automatic identification and data
  3514. capture techniques - Aztec Code bar code symbology specification
  3515. - SEMI T1-95 Specification for Back Surface Bar Code Marking of Silicon Wafers
  3516. (BC412) (1996)
  3517. - ANSI/AIM BC12-1998 - Uniform Symbology Specification Channel Code
  3518. - BS EN 798:1996 Bar coding - Symbology specifications - 'Codabar'
  3519. - AIM Europe ISS-X-24 - Uniform Symbology Specification Codablock-F (1995)
  3520. - ISO/IEC 15417:2007 Information technology - Automatic identification and data
  3521. capture techniques - Code 128 bar code symbology specification
  3522. - BS EN 12323:2005 AIDC technologies - Symbology specifications - Code 16K
  3523. - ISO/IEC 16388:2007 Information technology - Automatic identification and data
  3524. capture techniques - Code 39 bar code symbology specification
  3525. - ANSI/AIM BC6-2000 - Uniform Symbology Specification Code 49
  3526. - ANSI/AIM BC5-1995 - Uniform Symbology Specification Code 93
  3527. - AIM Uniform Symbology Specification Code One (1994)
  3528. - ISO/IEC 16022:2006 Information technology - Automatic identification and data
  3529. capture techniques - Data Matrix ECC200 bar code symbology specification
  3530. - ISO/IEC 21471:2020 Information technology - Automatic identification and data
  3531. capture techniques - Extended rectangular data matrix (DMRE) bar code
  3532. symbology specification
  3533. - AIM TSC1705001 (v 4.0 Draft 0.15) - Information technology - Automatic
  3534. identification and data capture techniques - Bar code symbology
  3535. specification - DotCode (Revised 28th May 2019)
  3536. - ISO/IEC 15420:2009 Information technology - Automatic identification and data
  3537. capture techniques - EAN/UPC bar code symbology specification
  3538. - AIMD014 (v 1.63) - Information technology, Automatic identification and data
  3539. capture techniques - Bar code symbology specification - Grid Matrix
  3540. (Released 9th Dec 2008)
  3541. - ISO/IEC 24723:2010 Information technology - Automatic identification and data
  3542. capture techniques - GS1 Composite bar code symbology specification
  3543. - ISO/IEC 24724:2011 Information technology - Automatic identification and data
  3544. capture techniques - GS1 DataBar bar code symbology specification
  3545. - ISO/IEC 20830:2021 Information technology - Automatic identification and data
  3546. capture techniques - Han Xin Code bar code symbology specification
  3547. - ISO/IEC 16390:2007 Information technology - Automatic identification and data
  3548. capture techniques - Interleaved 2 of 5 bar code symbology specification
  3549. - ISO/IEC 16023:2000 Information technology - International symbology
  3550. specification - MaxiCode
  3551. - ISO/IEC 24728:2006 Information technology - Automatic identification and data
  3552. capture techniques - MicroPDF417 bar code symbology specification
  3553. - ISO/IEC 15438:2015 Information technology - Automatic identification and data
  3554. capture techniques - PDF417 bar code symbology specification
  3555. - ISO/IEC 18004:2015 Information technology - Automatic identification and data
  3556. capture techniques - QR Code bar code symbology specification
  3557. - ISO/IEC 23941:2022 Information technology - Automatic identification and data
  3558. capture techniques - Rectangular Micro QR Code (rMQR) bar code symbology
  3559. specification
  3560. - AIMD/TSC15032-43 (v 0.99c) - International Technical Specification - Ultracode
  3561. Symbology (Draft) (Released 4th Nov 2015)
  3562. A number of other specification documents have also been referenced, such as
  3563. MIL-STD-1189 Rev. B (1989) (LOGMARS), USPS DMM 300 2006 (2011) (POSTNET, PLANET,
  3564. FIM) and USPS-B-3200 (2015) (IMAIL). Those not named include postal and delivery
  3565. company references in particular.
  3566. ### 7.5.2 General Standards
  3567. - AIM ITS/04-001 International Technical Standard - Extended Channel
  3568. Interpretations Part 1: Identification Schemes and Protocol (Released 24th
  3569. May 2004)
  3570. - AIM ITS/04-023 International Technical Standard - Extended Channel
  3571. Interpretations Part 3: Register (Version 2, February 2022)
  3572. - GS1 General Specifications Release 24.0 (Jan 2024)
  3573. - ANSI/HIBC 2.6-2016 - The Health Industry Bar Code (HIBC) Supplier Labeling
  3574. Standard
  3575. # Annex A. Character Encoding
  3576. This section is intended as a quick reference to the character sets used by
  3577. Zint. All symbologies use standard ASCII input as shown in section A.1, but some
  3578. support extended characters as shown in the subsequent section [A.2 Latin
  3579. Alphabet No. 1 (ISO/IEC 8859-1)].
  3580. ## A.1 ASCII Standard
  3581. The ubiquitous ASCII standard is well known to most computer users. It's
  3582. reproduced here for reference.
  3583. Hex 0 1 2 3 4 5 6 7
  3584. --- ------ ------ ------ ------ ------ ------ ------ ------
  3585. 0 `NUL` `DLE` `SPACE` `0` `@` `P` `` ` `` `p`
  3586. 1 `SOH` `DC1` `!` `1` `A` `Q` `a` `q`
  3587. 2 `STX` `DC2` `"` `2` `B` `R` `b` `r`
  3588. 3 `ETX` `DC3` `#` `3` `C` `S` `c` `s`
  3589. 4 `EOT` `DC4` `$` `4` `D` `T` `d` `t`
  3590. 5 `ENQ` `NAK` `%` `5` `E` `U` `e` `u`
  3591. 6 `ACK` `SYN` `&` `6` `F` `V` `f` `v`
  3592. 7 `BEL` `ETB` `'` `7` `G` `W` `g` `w`
  3593. 8 `BS` `CAN` `(` `8` `H` `X` `h` `x`
  3594. 9 `TAB` `EM` `)` `9` `I` `Y` `i` `y`
  3595. A `LF` `SUB` `*` `:` `J` `Z` `j` `z`
  3596. B `VT` `ESC` `+` `;` `K` `[` `k` `{`
  3597. C `FF` `FS` `,` `<` `L` `\` `l` `|`
  3598. D `CR` `GS` `-` `=` `M` `]` `m` `}`
  3599. E `SO` `RS` `.` `>` `N` `^` `n` `~`
  3600. F `SI` `US` `/` `?` `O` `_` `o` `DEL`
  3601. Table: {#tbl:ascii tag=": ASCII"}
  3602. ## A.2 Latin Alphabet No. 1 (ISO/IEC 8859-1)
  3603. ISO/IEC 8859-1 defines additional characters common in western European
  3604. languages like French, German, Italian and Spanish. This extension is the
  3605. default encoding of many barcodes (see Table @tbl:default_character_sets) when a
  3606. codepoint above hex 9F is encoded. Note that codepoints hex 80 to 9F are not
  3607. defined.
  3608. Hex 8 9 A B C D E F
  3609. --- ------ ------ ------ ------ ------ ------ ------ ------
  3610. 0 `NBSP` `°` `À` `Ð` `à` `ð`
  3611. 1 `¡` `±` `Á` `Ñ` `á` `ñ`
  3612. 2 `¢` `²` `Â` `Ò` `â` `ò`
  3613. 3 `£` `³` `Ã` `Ó` `ã` `ó`
  3614. 4 `¤` `´` `Ä` `Ô` `ä` `ô`
  3615. 5 `¥` `μ` `Å` `Õ` `å` `õ`
  3616. 6 `¦` `¶` `Æ` `Ö` `æ` `ö`
  3617. 7 `§` `·` `Ç` `×` `ç` `÷`
  3618. 8 `¨` `¸` `È` `Ø` `è` `ø`
  3619. 9 `©` `¹` `É` `Ù` `é` `ù`
  3620. A `ª` `º` `Ê` `Ú` `ê` `ú`
  3621. B `«` `»` `Ë` `Û` `ë` `û`
  3622. C `¬` `¼` `Ì` `Ü` `ì` `ü`
  3623. D `SHY` `½` `Í` `Ý` `í` `ý`
  3624. E `®` `¾` `Î` `Þ` `î` `þ`
  3625. F `¯` `¿` `Ï` `ß` `ï` `ÿ`
  3626. Table: {#tbl:iso_iec_8869_1 tag=": ISO/IEC 8859-1"}
  3627. # Annex B. Qt Backend QZint
  3628. Used internally by Zint Barcode Studio to display the preview, the Qt Backend
  3629. `QZint` renders a barcode by drawing the vector representation (see [5.5
  3630. Buffering Symbols in Memory (vector)]) provided by the Zint library `libzint`.
  3631. The main class is `Zint::QZint`, which has getter/setter properties that
  3632. correspond to the `zint_symbol` structure (see [5.7 Setting Options]), and a
  3633. main method `render()` which takes a Qt `QPainter` to paint with, and a `QRectF`
  3634. rectangular area specifying where to paint into:
  3635. ```c++
  3636. /* Encode and display barcode in `paintRect` using `painter`.
  3637. Note: legacy argument `mode` is not used */
  3638. void render(QPainter& painter, const QRectF& paintRect,
  3639. AspectRatioMode mode = IgnoreAspectRatio);
  3640. ```
  3641. `render()` will emit one of two Qt signals - `encoded` on successful encoding
  3642. and drawing, or `errored` on failure. The client can connect and act
  3643. appropriately, for instance:
  3644. ```c++
  3645. connect(qzint, SIGNAL(encoded()), SLOT(on_encoded()));
  3646. connect(qzint, SIGNAL(errored()), SLOT(on_errored()));
  3647. ```
  3648. where `qzint` is an instance of `Zint::QZint` and `on_encoded()` and
  3649. `on_error()` are Qt slot methods provided by the caller. On error, the error
  3650. value and message can be retrieved by the methods `getError()` and `lastError()`
  3651. respectively.
  3652. The other main method is `save_to_file()`:
  3653. ```c++
  3654. /* Encode and print barcode to file `filename`.
  3655. Only sets `getError()` on error, not on warning */
  3656. bool save_to_file(const QString& filename); // `ZBarcode_Print()`
  3657. ```
  3658. which takes a `filename` to output to. It too will emit an `errored` signal on
  3659. failure, returning `false` (but nothing on success, which just returns `true`).
  3660. Note that rotation is achieved through the setter method `setRotateAngleValue()`
  3661. (as opposed to the `rotate_angle` argument used by `ZBarcode_Print()`).
  3662. Various other methods are available, for instance methods for testing symbology
  3663. capabilities, and utility methods such as `defaultXdim()` and `getAsCLI()`.
  3664. For full details, see `"backend_qt/qzint.h"`.
  3665. # Annex C. Tcl Backend Binding
  3666. A Tcl binding is available in the `"backend_tcl`" sub-directory. To make on
  3667. Unix:
  3668. ```bash
  3669. cd backend_tcl
  3670. autoconf
  3671. ./configure
  3672. make
  3673. sudo make install
  3674. ```
  3675. For Windows, a Visual Studio 6.0 project file is available at
  3676. `"backend_tcl\zint_tcl.dsp"`. This can also be opened (and converted) by more
  3677. modern Visual Studio versions, though some fixing up of the project
  3678. configuration will likely be required.
  3679. Once built and installed, invoke the Tcl/Tk CLI `"wish"`:
  3680. ```bash
  3681. wish
  3682. ```
  3683. and ignoring the Tk window click back to the command prompt `"%"` and type:
  3684. ```bash
  3685. require package zint
  3686. zint help
  3687. ```
  3688. which will show the usage message, with options very similiar to the Zint CLI.
  3689. (One notable difference is that boolean options such as `-bold` take a `1` or
  3690. `0` as an argument.)
  3691. A demonstration Tcl/Tk program which is also useful in itself is available at
  3692. `"backend_tcl/demo/demo.tcl"`. To run type:
  3693. ```bash
  3694. wish demo/demo.tcl
  3695. ```
  3696. which will display the following window.
  3697. ![Tcl/Tk demonstration program window](images/tcl_demo.png){.pop}
  3698. You can select the symbology, enter the data to encode, and set options (which
  3699. are the same as those given in the usage message). A raster preview of the
  3700. configured barcode is displayed once the `"Generate"` button is pressed.
  3701. # Annex D. Man Page ZINT(1)