ch27s03.html
50.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Example scripts</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch27.html" title="Chapter 27. QR (2D-Barcode)"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Example scripts</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 27. QR (2D-Barcode)</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Example scripts"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2618696"></a>Example scripts</h2></div></div></div>
<p>The following sections shows a number of example script that can be used as a base for
further refinement.</p>
<div class="sect2" title="Example 1 - Store QR code to file"><div class="titlepage"><div><div><h3 class="title"><a name="id2618715"></a>Example 1 - Store QR code to file</h3></div></div></div>
<p>QR Barcode with specified version and stored to a file</p>
<p>
</p><div class="example"><a name="example.qrexample03"></a><p class="title"><b>Example 27.6. Storing image to a file (<code class="filename">qrexample03.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 3 : QR Barcode with specified version and stored to a file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Data to be encoded</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$data</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">01234567</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-var">$version</span><span class="hl-code"> = </span><span class="hl-number">3</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Use QR version 3</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$fileName</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">qrexample03.png</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder and let the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> decide a suitable error level</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-var">$version</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code"> = </span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_IMAGE</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size (quite big)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-number">5</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Store the barcode in the specifed file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-code">,</span><span class="hl-var">$fileName</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">list</span><span class="hl-brackets">(</span><span class="hl-var">$version</span><span class="hl-code">,</span><span class="hl-var">$errorcorrection</span><span class="hl-brackets">)</span><span class="hl-code"> = </span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">GetQRInfo</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">echo</span><span class="hl-code"> </span><span class="hl-quotes">"</span><span class="hl-string">QR Barcode, (<b>Version: </span><span class="hl-var">$version</span><span class="hl-string">-</span><span class="hl-var">$errorcorrection</span><span class="hl-string"></b>), image stored in file </span><span class="hl-var">$fileName</span><span class="hl-quotes">"</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break">
</p>
</div>
<div class="sect2" title="Example 2 - Specified error correction level"><div class="titlepage"><div><div><h3 class="title"><a name="id2618745"></a>Example 2 - Specified error correction level</h3></div></div></div>
<p>QR Barcode with specified version and error correction level</p>
<p>
</p><div class="example"><a name="example.qrexample04"></a><p class="title"><b>Example 27.7. Specified error correction level (<code class="filename">qrexample04.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 4 : QR Barcode with specified version and error correction level</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Data to be encoded</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$data</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">01234567</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-var">$version</span><span class="hl-code"> = </span><span class="hl-number">12</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Use QR version 4</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$corrlevel</span><span class="hl-code"> = </span><span class="hl-identifier">QRCapacity</span><span class="hl-code">::</span><span class="hl-identifier">ErrH</span><span class="hl-code"> ; </span><span class="hl-comment">//</span><span class="hl-comment"> Level H error correction (the highest possible)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder using the specified</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> QR version and error correction</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-var">$version</span><span class="hl-code">,</span><span class="hl-var">$corrlevel</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code"> = </span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_IMAGE</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-number">3</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Store the barcode in the specifed file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.qrexample04"></a><p class="title"><b>Figure 27.14. Specified error correction level <code class="uri"><a class="uri" href="example_src/qrexample04.html" target="_top">(<code class="filename">qrexample04.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/qrexample04.png" alt="Specified error correction level (qrexample04.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Example 3 - Manual specified encoding"><div class="titlepage"><div><div><h3 class="title"><a name="id2618804"></a>Example 3 - Manual specified encoding</h3></div></div></div>
<p>QR Barcode with manually specified encodation</p>
<p>
</p><div class="example"><a name="example.qrexample05"></a><p class="title"><b>Example 27.8. QR Barcode with manually specified encodation (<code class="filename">qrexample05.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 5 : QR Barcode with manually specified encodation</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Data to be encoded</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> We want the data to be encoded using alphanumeric encoding even though</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> it is only numbers</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$data</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-identifier">QREncoder</span><span class="hl-code">::</span><span class="hl-identifier">MODE_ALPHANUM</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">01234567</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">
</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$version</span><span class="hl-code"> = </span><span class="hl-number">3</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Use QR version 3</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$corrlevel</span><span class="hl-code"> = </span><span class="hl-identifier">QRCapacity</span><span class="hl-code">::</span><span class="hl-identifier">ErrH</span><span class="hl-code"> ; </span><span class="hl-comment">//</span><span class="hl-comment"> Level H error correction (the highest possible)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder using the specified</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> QR version and error correction</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-var">$version</span><span class="hl-code">,</span><span class="hl-var">$corrlevel</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code"> = </span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_IMAGE</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-number">4</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Store the barcode in the specifed file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.qrexample05"></a><p class="title"><b>Figure 27.15. QR Barcode with manually specified encodation <code class="uri"><a class="uri" href="example_src/qrexample05.html" target="_top">(<code class="filename">qrexample05.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/qrexample05.png" alt="QR Barcode with manually specified encodation (qrexample05.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Example 4 - JPEG image format"><div class="titlepage"><div><div><h3 class="title"><a name="id2618868"></a>Example 4 - JPEG image format</h3></div></div></div>
<p>QR Barcode with image in JPG format</p>
<p>
</p><div class="example"><a name="example.qrexample06"></a><p class="title"><b>Example 27.9. QR Barcode with image in JPG format (<code class="filename">qrexample06.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 6 : QR Barcode with image in JPG format</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$data</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">ABCDEFGH01234567</span><span class="hl-quotes">'</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Data to be encoded</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$version</span><span class="hl-code"> = -</span><span class="hl-number">1</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> -1 = Let the library decide version (same as default)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$corrlevel</span><span class="hl-code"> = -</span><span class="hl-number">1</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> -1 = Let the library decide error correction level (same as default)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder using the specified</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> QR version and error correction</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-var">$version</span><span class="hl-code">,</span><span class="hl-var">$corrlevel</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">=</span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_IMAGE</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use JPEG format with 80% quality level</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetImgFormat</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpeg</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-number">80</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-number">4</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Store the barcode in the specifed file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.qrexample06"></a><p class="title"><b>Figure 27.16. QR Barcode with image in JPG format <code class="uri"><a class="uri" href="example_src/qrexample06.html" target="_top">(<code class="filename">qrexample06.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/qrexample06.png" alt="QR Barcode with image in JPG format (qrexample06.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Example 5 - Multiple manual encoding"><div class="titlepage"><div><div><h3 class="title"><a name="id2618932"></a>Example 5 - Multiple manual encoding</h3></div></div></div>
<p>QR Barcode with multiple manually specified encodation schema. </p>
<p>
</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
<p>Normally there would be no need to ever use manually specified
encodation)</p>
</div><p>
</p>
<p>
</p><div class="example"><a name="example.qrexample07"></a><p class="title"><b>Example 27.10. multiple manually specified encodation schema. (<code class="filename">qrexample07.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 7 : QR Barcode with multiple manually specified encodation schemas</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> (</span><span class="hl-inlinedoc">Note:</span><span class="hl-comment"> Normally there would be no need to ever use manually specified encodation)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Data to be encoded</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$data</span><span class="hl-code"> = </span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-code">
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-identifier">QREncoder</span><span class="hl-code">::</span><span class="hl-identifier">MODE_ALPHANUM</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">01234567</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">,
</span><span class="hl-reserved">array</span><span class="hl-brackets">(</span><span class="hl-identifier">QREncoder</span><span class="hl-code">::</span><span class="hl-identifier">MODE_NUMERIC</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">89012345</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">
</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder (automatically determined QR version and</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> error correction level)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code"> = </span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_IMAGE</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-number">4</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Store the barcode in the specifed file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.qrexample07"></a><p class="title"><b>Figure 27.17. multiple manually specified encodation schema. <code class="uri"><a class="uri" href="example_src/qrexample07.html" target="_top">(<code class="filename">qrexample07.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/qrexample07.png" alt="multiple manually specified encodation schema. (qrexample07.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Example 6 - Reading data from file"><div class="titlepage"><div><div><h3 class="title"><a name="id2619008"></a>Example 6 - Reading data from file</h3></div></div></div>
<p>QR Barcode with data read from file</p>
<p>
</p><div class="example"><a name="example.qrexample08"></a><p class="title"><b>Example 27.11. data read from file (<code class="filename">qrexample08.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 8 : QR Barcode with data read from file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/jpgraph.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$readFromFilename</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">qr-input.txt</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder and let the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> decide a suitable QR version and error level</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code">=</span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">=</span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_IMAGE</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size (quite big)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-number">5</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> .. send the barcode back to the browser for the data in the file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">StrokeFromFile</span><span class="hl-brackets">(</span><span class="hl-var">$readFromFilename</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.qrexample08"></a><p class="title"><b>Figure 27.18. data read from file <code class="uri"><a class="uri" href="example_src/qrexample08.html" target="_top">(<code class="filename">qrexample08.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/qrexample08.png" alt="data read from file (qrexample08.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Example 7 - Adjusting colors"><div class="titlepage"><div><div><h3 class="title"><a name="id2619074"></a>Example 7 - Adjusting colors</h3></div></div></div>
<p>QR Barcode with data read from file and different colors</p>
<p>
</p><div class="example"><a name="example.qrexample09"></a><p class="title"><b>Example 27.12. (<code class="filename">qrexample09.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 9 : QR Barcode with data read from file and different colors</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/jpgraph.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$readFromFilename</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">qr-input.txt</span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder and let the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> decide a suitable QR version and error level</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code"> = </span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_IMAGE</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size (quite big)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-number">5</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use blue and white colors instead</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">navy</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">white</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> .. send the barcode back to the browser for the data in the file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">StrokeFromFile</span><span class="hl-brackets">(</span><span class="hl-var">$readFromFilename</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.qrexample09"></a><p class="title"><b>Figure 27.19. <code class="uri"><a class="uri" href="example_src/qrexample09.html" target="_top">(<code class="filename">qrexample09.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/qrexample09.png" alt="(qrexample09.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Example 8 - Setting error correction level"><div class="titlepage"><div><div><h3 class="title"><a name="id2619119"></a>Example 8 - Setting error correction level</h3></div></div></div>
<p>Specified error correction level</p>
<p>
</p><div class="example"><a name="example.qrexample10"></a><p class="title"><b>Example 27.13. Specified error correction level (<code class="filename">qrexample10.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 10 : Specified error correction level</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-var">$data</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">ABCDEFGH01234567</span><span class="hl-quotes">'</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Data to be encoded</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$version</span><span class="hl-code"> = -</span><span class="hl-number">1</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> -1 = Let the library decide version (same as default)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$corrlevel</span><span class="hl-code"> = </span><span class="hl-identifier">QRCapacity</span><span class="hl-code">::</span><span class="hl-identifier">ErrH</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Error correction level H (Highest possible)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder using the specified</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> QR version and error correction</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-var">$version</span><span class="hl-code">,</span><span class="hl-var">$corrlevel</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code"> = </span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_IMAGE</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-number">3</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set color</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetColor</span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">brown</span><span class="hl-quotes">'</span><span class="hl-code">,</span><span class="hl-quotes">'</span><span class="hl-string">white</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Store the barcode in the specifed file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break"> </p><div class="figure"><a name="fig.qrexample10"></a><p class="title"><b>Figure 27.20. Specified error correction level <code class="uri"><a class="uri" href="example_src/qrexample10.html" target="_top">(<code class="filename">qrexample10.php</code>)</a></code> </b></p><div class="figure-contents"> <span class="inlinemediaobject"><img src="images/qrexample10.png" alt="Specified error correction level (qrexample10.php)"></span> </div></div><p><br class="figure-break">
</p>
</div>
<div class="sect2" title="Example 9 - Generating ASCII output"><div class="titlepage"><div><div><h3 class="title"><a name="id2619201"></a>Example 9 - Generating ASCII output</h3></div></div></div>
<p>Using the ASCII backend</p>
<p>
</p><div class="example"><a name="example.qrexample12"></a><p class="title"><b>Example 27.14. Using the ASCII backend (<code class="filename">qrexample12.php</code>) </b></p><div class="example-contents"> <div class="hl-main"><table class="hl-table" width="100%"><tr><td class="hl-gutter" align="right" valign="top"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="hl-main" valign="top"><pre><span class="hl-inlinetags"><?php</span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> Include the library</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-reserved">require_once</span><span class="hl-code"> </span><span class="hl-brackets">(</span><span class="hl-quotes">'</span><span class="hl-string">jpgraph/QR/qrencoder.inc.php</span><span class="hl-quotes">'</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Example 11 : Generate postscript output</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$data</span><span class="hl-code"> = </span><span class="hl-quotes">'</span><span class="hl-string">ABCDEFGH01234567</span><span class="hl-quotes">'</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Data to be encoded</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$version</span><span class="hl-code"> = -</span><span class="hl-number">1</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> -1 = Let the library decide version (same as default)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$corrlevel</span><span class="hl-code"> = </span><span class="hl-identifier">QRCapacity</span><span class="hl-code">::</span><span class="hl-identifier">ErrH</span><span class="hl-code">; </span><span class="hl-comment">//</span><span class="hl-comment"> Error correction level H (Highest possible)</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$modulewidth</span><span class="hl-code"> = </span><span class="hl-number">1</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Create a new instance of the encoder using the specified</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-comment">//</span><span class="hl-comment"> QR version and error correction</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$encoder</span><span class="hl-code"> = </span><span class="hl-reserved">new</span><span class="hl-code"> </span><span class="hl-identifier">QREncoder</span><span class="hl-brackets">(</span><span class="hl-var">$version</span><span class="hl-code">,</span><span class="hl-var">$corrlevel</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Use the image backend</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code"> = </span><span class="hl-identifier">QRCodeBackendFactory</span><span class="hl-code">::</span><span class="hl-identifier">Create</span><span class="hl-brackets">(</span><span class="hl-var">$encoder</span><span class="hl-code">, </span><span class="hl-identifier">BACKEND_ASCII</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Set the module size</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">SetModuleWidth</span><span class="hl-brackets">(</span><span class="hl-var">$modulewidth</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-comment">//</span><span class="hl-comment"> Store the barcode in the specifed file</span><span class="hl-comment"></span><span class="hl-code">
</span><span class="hl-var">$ps_str</span><span class="hl-code"> = </span><span class="hl-var">$backend</span><span class="hl-code">-></span><span class="hl-identifier">Stroke</span><span class="hl-brackets">(</span><span class="hl-var">$data</span><span class="hl-brackets">)</span><span class="hl-code">;
</span><span class="hl-reserved">echo</span><span class="hl-code"> </span><span class="hl-quotes">'</span><span class="hl-string"><pre></span><span class="hl-quotes">'</span><span class="hl-code">.</span><span class="hl-var">$ps_str</span><span class="hl-code">.</span><span class="hl-quotes">'</span><span class="hl-string"></pre></span><span class="hl-quotes">'</span><span class="hl-code">;
</span><span class="hl-inlinetags">?></span></pre></td></tr></table></div></div></div><p><br class="example-break">
</p>
<div class="figure"><a name="id2619239"></a><p class="title"><b>Figure 27.21. QR With ASCII rendering</b></p><div class="figure-contents">
<div class="mediaobject"><img src="images/qr-ASCII.png" alt="QR With ASCII rendering"></div>
</div></div><br class="figure-break">
</div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="ch27.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>