libs-imp-zint.mkxl /size: 3777 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=m-zint,
3%D        version=2010.12.07,
4%D          title=\CONTEXT\ Extra Modules,
5%D       subtitle=Zint Barcode Generator,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D Using \type {zint} seems to be the easiest way to generate (PDF417) barcodes so
15%D therefore we now have this module. There are proper (also windows) binaries at:
16%D
17%D \starttyping
18%D http://www.zint.org.uk
19%D \stoptyping
20%D
21%D There is a bit more code than needed as we want to be able to feed names.
22%D
23%D % e:\tex-context\tex\texmf-win64\bin\lib\luametatex\zint\libzint.dll
24
25% \enabletrackers[*res*]
26
27\registerctxluafile{libs-imp-zint}{autosuffix}
28
29\unprotect
30
31\definefont[usedzintfont][dejavusansmono at 10bp]
32
33\permanent\protected\def\barcode[#S#1]% [alternative=,text=]
34  {\bgroup
35   \usedzintfont
36   \getdummyparameters
37     [\c!alternative=,\c!text=,\c!option=,#1]%
38   \scale
39     [#1]%
40     {\clf_zint
41         code   {\dummyparameter\c!alternative}
42         text   {\dummyparameter\c!text}
43         option {\dummyparameter\c!option}
44      \relax}%
45   \egroup}
46
47\protect
48
49\continueifinputfile{libs-imp-zint.mkxl}
50
51\starttext
52
53\dontcomplain
54
55% \dorecurse{1}{
56%     \startTEXpage
57%         \barcode[alternative=PDF417,text={Hans Hagen}]%
58%         \blank
59%         \barcode[alternative=PDF417,text={Ton Otten}]%
60%         \blank
61%         \barcode[alternative=ISBN,text=9789490688011]%
62%         \blank
63%         \barcode[alternative=isbn,text=9789490688011,width=3cm]%
64%         \blank
65%         \dontleavehmode
66%         \barcode[alternative=qr code,text={This is ConTeXt MKIV : #1}]
67%         \barcode[alternative=qr code,text={This is ConTeXt LMTX}]
68%         \barcode[alternative=qr code,text={\cldloadfile{tufte}},width=3cm]
69%         \blank
70%         \barcode[alternative=datamatrix,text=whatever,width=3cm,option=square]
71%         \scale[width=3cm,height=3cm]{\barcode[alternative=datamatrix,text=whatever,width=3cm,option=square]}
72%         \barcode[alternative=datamatrix,text={helloworld}]
73%         \barcode[alternative=datamatrix,text={hello world}]
74%     \stopTEXpage
75% }
76
77    \startTEXpage
78        \startluacode
79            for i=1,100 do
80                context.dontleavehmode()
81                context.barcode {
82                    alternative = "datamatrix",
83                    text        = string.rep("!",i),
84                }
85                context.space()
86                context.allowbreak()
87            end
88        \stopluacode
89    \stopTEXpage
90
91    \startTEXpage
92        \startluacode
93            for i=1,100 do
94                context.dontleavehmode()
95                context.barcode {
96                    alternative = "datamatrix",
97                    text        = string.rep("!",i),
98                    option      = "square",
99                }
100                context.space()
101                context.allowbreak()
102            end
103        \stopluacode
104    \stopTEXpage
105
106        \startluacode
107            for i=1,25 do
108                context.startTEXpage()
109                context.dontleavehmode()
110                context(i)
111                context.space()
112                context.barcode {
113                    alternative = "datamatrix",
114                    text        = string.rep("!",i),
115                }
116                context.space()
117                context.barcode {
118                    alternative = "datamatrix",
119                    text        = string.rep("!",i),
120                    option      = "square",
121                }
122                context.stopTEXpage()
123            end
124        \stopluacode
125\stoptext
126