Debian Codegraph @

texmf-dist/tex/xelatex/businesscard-qrcode/businesscard-qrcode.cls

raw
1 % Author: Marc Wäckerlin
2 % License: LGPL
3 \NeedsTeXFormat{LaTeX2e}
4 \ProvidesClass{businesscard-qrcode}[2018/08/15 version 1.2 ready for ctan]
5
6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 % option evaluation
8 \RequirePackage{kvoptions}
9 \SetupKeyvalOptions{
10 family=BCQ,
11 prefix=BCQ@
12 }
13 \DeclareStringOption[89mm]{paperwidth}
14 \DeclareStringOption[59mm]{paperheight}
15 \DeclareStringOption[85mm]{contentwidth}
16 \DeclareStringOption[55mm]{contentheight}
17 \DeclareStringOption[8pt]{fontsize}
18 \DeclareStringOption[2mm]{padding}
19 \DeclareStringOption[2]{cutdist}
20 \DeclareStringOption[1]{cutlen}
21 \DeclareStringOption[0.50]{textwidth}
22 \DeclareStringOption[0.40]{qrwidth}
23 \DeclareStringOption[de]{lang}
24 \DeclareBoolOption[true]{address}
25 \DeclareComplementaryOption{noaddress}{address}
26 \DeclareBoolOption[true]{hint}
27 \DeclareComplementaryOption{nohint}{hint}
28 \DeclareBoolOption[true]{icon}
29 \DeclareComplementaryOption{noicon}{icon}
30 \DeclareBoolOption[true]{rightalign}
31 \DeclareComplementaryOption{leftalign}{rightalign}
32 \DeclareBoolOption[true]{iconleft}
33 \DeclareComplementaryOption{iconright}{iconleft}
34 \DeclareBoolOption[true]{fill}
35 \DeclareComplementaryOption{nofill}{fill}
36 \DeclareBoolOption[true]{qrfirst}
37 \DeclareComplementaryOption{textfirst}{qrfirst}
38 \DeclareBoolOption[true]{https}
39 \DeclareComplementaryOption{www}{https}
40 \DeclareDefaultOption{\@unknownoptionerror}
41 \ProcessKeyvalOptions*
42
43
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 % definitions from the options
46 \def\content{paperwidth=\BCQ@contentwidth,paperheight=\BCQ@contentheight}
47 \def\papersize{width=\BCQ@paperwidth,height=\BCQ@paperheight}
48 \def\padding{\BCQ@padding} % padding around the content
49 \def\border{\BCQ@cutdist} % distance between start of cutmark and content in mm
50 \def\cutlen{\BCQ@cutlen} % length of ct marks in mm
51 \def\textpercents{\BCQ@textwidth} % size of text part 0..1
52 \def\imagepercents{\BCQ@qrwidth} % size of qrcode image part 0..1
53 \def\lang{\BCQ@lang}
54 \def\protdisplay{\ifBCQ@https https://\else www.\fi}
55 \def\protprefix{\ifBCQ@https https://\fi}
56 \ifBCQ@address\def\printaddress{}\fi
57
58
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 % global dependencies and settings
61 \LoadClass[\BCQ@fontsize]{extarticle}
62 \RequirePackage{marvosym}
63 \RequirePackage{fontawesome}
64 \RequirePackage[final]{qrcode}
65 \RequirePackage{etoolbox}
66 \RequirePackage{DejaVuSans}
67 \RequirePackage[T1]{fontenc}
68 \RequirePackage{wrapfig}
69 \RequirePackage[\content,top=\padding,left=\padding,right=\padding,bottom=\padding]{geometry}
70 %\RequirePackage{pbox}
71 \RequirePackage{varwidth}
72 \RequirePackage{calc}
73 \pagestyle{empty}
74 \setlength{\parindent}{0pt}
75 \renewcommand*\familydefault{\sfdefault}
76 \setlength{\fboxsep}{0pt}
77
78
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 % data registration
81 \newcommand\registerData[1]{
82 \expandafter\newcommand\csname #1\endcsname[1]{
83 \expandafter\def\csname X#1\endcsname{##1}
84 }
85 }
86 \registerData{type}
87 \registerData{givennames}
88 \registerData{familynames}
89 \registerData{honoricprefix}
90 \registerData{honoricsuffix}
91 \registerData{additionalnames}
92 \registerData{pobox}
93 \registerData{extaddr}
94 \registerData{street}
95 \registerData{city}
96 \registerData{region}
97 \registerData{zip}
98 \registerData{country}
99 \registerData{phone}
100 \registerData{email}
101 \registerData{jabber}
102 \registerData{matrixorg}
103 \registerData{cloud}
104 \registerData{homepage}
105 \registerData{wordpress}
106 \registerData{drupal}
107 \registerData{joomla}
108 \registerData{wikipedia}
109 \registerData{link}
110 \registerData{world}
111 \registerData{git}
112 \registerData{gitea}
113 \registerData{github}
114 \registerData{facebook}
115 \registerData{twitter}
116 \registerData{youtube}
117 \registerData{google}
118 \registerData{pgpurl}
119 \registerData{pgpfingerprint}
120
121
122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123 % auxiliary commands
124 \newcommand\enforceright{\leftskip0pt plus 1fill\rightskip0pt}
125 \newcommand\exec[1]{\csname #1\endcsname}
126 \newcommand\insa[3][]{\ifcsdef{#2}{
127
128 \ifBCQ@iconleft
129 \ifBCQ@icon\parbox{1em}{\centering\exec{#3}}\ \fi\ifBCQ@hint{\tiny#1}\fi\ifBCQ@fill\hfill\fi\exec{#2}
130 \else
131 \ifBCQ@hint{\tiny#1\ }\fi\exec{#2}\ifBCQ@fill\hfill\fi\ifBCQ@icon\ \parbox{1em}{\centering\exec{#3}}\fi
132 \fi
133 }{}}
134 \newcommand\ifexists[2]{\ifcsdef{#1}{#2}{}}
135 \newcommand\ifboth[3]{\ifcsdef{#1}{\ifcsdef{#2}{#3}{}}{}}
136 \newcommand\ifany[3]{\ifcsdef{#1}{#3}{\ifcsdef{#2}{#3}{}}}
137 \newcommand\cond[1]{\ifcsdef{#1}{\exec{#1}}{}}
138 \newcommand\heightscale{\dimexpr\textheight-\ifcsempty{name}{0em}{2em}-\ifcsdef{Xpgpfingerprint}{2em}{0em}-\ifcsdef{Xadditionalnames}{2em}{0em}\relax}
139
140
141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
142 % name - assemble full name from the parts, such as Xgivennames and Xfamilynames
143 \newcommand\name{\ifexists{Xhonoricprefix}{\Xhonoricprefix\ }\ifexists{Xgivennames}{\Xgivennames\ }\ifexists{Xfamilynames}{\Xfamilynames}\ifexists{Xhonoricsuffix}{\ \Xhonoricsuffix}}
144
145
146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147 % vcard - the content of the vcard
148 \newcommand\vcard{BEGIN:VCARD^^J
149 VERSION:4.0^^J
150 N:\cond{Xfamilynames};\cond{Xgivennames};\cond{Xadditionalnames};\cond{Xhonoricprefix};\cond{Xhonoricsuffix}^^J
151 FN:\name\ifexists{Xadditionalnames}{\ifcsempty{name}{}{\ }\Xadditionalnames}^^J
152 \ifexists{printaddress}{ADR\ifexists{Xtype}{;TYPE=\Xtype}:\cond{Xpobox};\cond{Xextaddr};\cond{Xstreet};\cond{Xcity};\cond{Xregion};\cond{Xzip};\cond{Xcountry}^^J}
153 \ifexists{Xphone}{TEL;VALUE=uri;TYPE=\ifexists{Xtype}{\Xtype,}voice,text:tel:\Xphone^^J}
154 \ifexists{Xemail}{EMAIL\ifexists{Xtype}{;TYPE=\Xtype}:\Xemail^^J}
155 \ifexists{Xjabber}{IMPP;TYPE=XMPP:\Xjabber^^J}
156 \ifexists{Xmatrixorg}{IMPP;TYPE=MATRIX:\Xmatrixorg^^J}
157 \ifexists{Xcloud}{URL:https://nextcloud.com/federation/\#\Xcloud^^J}
158 \ifexists{Xhomepage}{URL:https://\Xhomepage^^J}
159 \ifexists{Xwordpress}{URL:https://\Xwordpress^^J}
160 \ifexists{Xdrupal}{URL:https://\Xdrupal^^J}
161 \ifexists{Xjoomla}{URL:https://\Xjoomla^^J}
162 \ifexists{Xwikipedia}{URL:https://\lang.wikipedia.org/wiki/\Xwikipedia^^J}
163 \ifexists{Xlink}{URL:https://\Xlink^^J}
164 \ifexists{Xworld}{URL:https://\Xworld^^J}
165 \ifexists{Xgit}{URL:https://\Xgit^^J}
166 \ifexists{Xgitea}{URL:https://\Xgitea^^J}
167 \ifexists{Xgithub}{URL:https://github.com/\Xgithub^^J}
168 \ifexists{Xfacebook}{URL:https://facebook.com/\Xfacebook^^J}
169 \ifexists{Xtwitter}{URL:https://twitter.com/\Xtwitter^^J}
170 \ifexists{Xyoutube}{URL:https://youtube.com/user/\Xyoutube^^J}
171 \ifexists{Xgoogle}{URL:https://plus.google.com/+\Xgoogle^^J}
172 \ifexists{Xpgpurl}{KEY;MEDIATYPE=application/pgp-keys:\Xpgpurl^^J}
173 \ifexists{Xpgpfingerprint}{KEY:data:application/x-pgp-fingerprint,\Xpgpfingerprint^^J}
174 END:VCARD^^J}
175
176
177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178 % address - the address as shown in the textbox
179 \newcommand\address{
180
181 \cond{Xpobox}
182
183 \cond{Xextaddr}
184
185 \cond{Xstreet}
186
187 \cond{Xzip} \cond{Xcity}
188
189 \cond{Xregion} \cond{Xcountry}
190
191 }
192
193
194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195 % inserttext - assemble the textbox
196 \newcommand\inserttext{
197 %\frame
198 {
199 \begin{minipage}[c][\heightscale][c]{\textpercents\textwidth}
200 \ifBCQ@rightalign\begin{flushright}\fi
201 \ifexists{printaddress}{
202 \ifBCQ@iconleft
203 \ifBCQ@icon\parbox[c]{1em}{\faMapMarker}\ \ifBCQ@fill\hfill\fi\fi
204 %\frame{
205 %\pbox[t]{\dimexpr\textwidth-2em\relax}{
206 \begin{varwidth}{\dimexpr\textwidth-2em\relax}
207 \ifBCQ@rightalign\enforceright\fi\address
208 \end{varwidth}
209 %}
210 %}
211 \else
212 %\pbox[t]{\dimexpr\textwidth-2em\relax}{
213 \begin{varwidth}{\dimexpr\textwidth-2em\relax}
214 \ifBCQ@rightalign\enforceright\fi\address
215 \end{varwidth}
216 %}
217 \ifBCQ@icon\ifBCQ@fill\hfill\fi\ \parbox[c]{1em}{\faMapMarker}\fi
218 \fi
219 \vspace{1em}
220 }
221
222 \insa[tel:]{Xphone}{faMobile}\insa[mailto:]{Xemail}{Email}\insa[xmpp]{Xjabber}{faCommentsO}\insa[matrix.org]{Xmatrixorg}{faCommentsO}\insa[nextcloud-id]{Xcloud}{faCloud}\insa[\protdisplay]{Xhomepage}{faHome}\insa[\protdisplay]{Xwordpress}{faWordpress}\insa[\protdisplay]{Xdrupal}{faDrupal}\insa[\protdisplay]{Xjoomla}{faJoomla}\insa[{\protprefix}\lang.wikipedia.org/wiki/]{Xwikipedia}{faWikipediaW}\insa[\protdisplay]{Xlink}{faLink}\insa[\protdisplay]{Xworld}{faGlobe}\insa[\protdisplay]{Xgit}{faGit}\insa[\protdisplay]{Xgitea}{faGithubAlt}\insa[{\protprefix}github.com/]{Xgithub}{faGithub}\insa[{\protprefix}facebook.com/]{Xfacebook}{faFacebook}\insa[{\protprefix}twitter.com/]{Xtwitter}{faTwitter}\insa[{\protprefix}youtube.com/user/]{Xyoutube}{faYoutube}\insa[{\protprefix}plus.google.com/+]{Xgoogle}{faGooglePlus}
223
224 \ifBCQ@rightalign\end{flushright}\fi
225 \end{minipage}
226 }
227 }
228
229
230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231 % insertqrcode - insert the qr-code
232 \newcommand\insertqrcode{
233 %\frame
234 {
235 \begin{minipage}[c][\heightscale][c]{\imagepercents\textwidth}
236 \qrcode[level=Q,version=0,height=\textwidth]{\vcard}
237 \end{minipage}
238 }
239 }
240
241
242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 % insertname - insert the name on the top
244 \newcommand\insertname{
245 %\frame
246 %\begin{minipage}{\textwidth}
247 %\pbox[t]{0.9\textwidth}
248 {\bfseries
249
250 \cond{name}
251
252 \cond{Xadditionalnames}
253
254 }
255 %\end{minipage}
256 }
257
258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 % drawcard - assemble all blocks into the visiting card
260 \newcommand\drawcard{
261 \ifBCQ@rightalign\begin{flushright}\fi
262 \insertname
263 \noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}} % horizontal line
264 \vfill
265 \ifBCQ@qrfirst
266 \insertqrcode
267 \hfill
268 \inserttext
269 \else
270 \inserttext
271 \hfill
272 \insertqrcode
273 \fi
274 \ifexists{Xpgpfingerprint}{
275 \vfill
276 \ifBCQ@iconleft
277 \faLock\ifBCQ@hint{\tiny\ pgp}\fi\hfill{\small\Xpgpfingerprint}
278 \else
279 {\small\Xpgpfingerprint}\hfill\ifBCQ@hint{\tiny{pgp\ }}\fi\faLock
280 \fi
281 }
282 \ifBCQ@rightalign\end{flushright}\fi
283 }
284
285
286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 % cut / crop marks
288 \RequirePackage[\papersize,noinfo,center,pdftex]{crop}
289 \newcommand\tl{
290 \begin{picture}(0,0)
291 \thinlines\unitlength1mm
292 \put(-\border,0){\line(1,0){\cutlen}}
293 \put(0,\border){\line(0,-1){\cutlen}}
294 \end{picture}
295 }
296 \newcommand\tr{
297 \begin{picture}(0,0)
298 \thinlines\unitlength1mm
299 \put(\border,0){\line(-1,0){\cutlen}}
300 \put(0,\border){\line(0,-1){\cutlen}}
301 \end{picture}
302 }
303 \newcommand\bl{
304 \begin{picture}(0,0)
305 \thinlines\unitlength1mm
306 \put(-\border,0){\line(1,0){\cutlen}}
307 \put(0,-\border){\line(0,1){\cutlen}}
308 \end{picture}
309 }
310 \newcommand\br{
311 \begin{picture}(0,0)
312 \thinlines\unitlength1mm
313 \put(\border,0){\line(-1,0){\cutlen}}
314 \put(0,-\border){\line(0,1){\cutlen}}
315 \end{picture}
316 }
317 \cropdef[]\tl\tr\bl\br{cut}
318 \crop[cut]