summaryrefslogtreecommitdiffstats
path: root/kbarcode/mybarcode.cpp
blob: 375e05e6caacdceab5742803a0832ee91bdda2e9 (plain)
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
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
f/***************************************************************************
                          barcode.cpp  -  description
                             -------------------
    begin                : Die Apr 23 2002
    copyright            : (C) 2002 by Dominik Seichter
    email                : domseichter@web.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "sqltables.h"
#include "barcodecache.h"

#include "mybarcode.h"
#include <stdio.h>

// TQt includes
#include <tqdir.h>
#include <tqpainter.h>
#include <tqpaintdevicemetrics.h>
#include <tqsqlquery.h>

// KDE includes
#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kprocess.h>
#include <kstandarddirs.h>
#include <ktempfile.h>

#define BARCODE_MARGIN 10     /* Margin added by GNU Barcode to the barcodes */

TQValueList<barcodeFormat> codes;

void init() {
    BarCode::setHaveBarcode();
}

bool barcodeData::operator==( const struct barcodeData d ) const {
    bool b = ( value == d.value && type == d.type &&
               scale == d.scale && text == d.text );

    if( BarCode::hasFeature( type, TBARCODEADV ) )
        b = ( b && tbarcode == d.tbarcode );

    if( BarCode::hasFeature( type, DATAMATRIX ) )
        b = ( b && datamatrix == d.datamatrix );

    if( BarCode::hasFeature( type, PDF417BARCODE ) )
        b = ( b && pdf417 == d.pdf417 );

    return b;
};

BarCode::BarCode( const barcodeData* data )
{
    barcode = *data;
    m_index = 0;
}

BarCode::BarCode()
{
    fillDefault( &barcode );
    m_index = 0;    
}

BarCode::~BarCode()
{
}

const TQPixmap BarCode::pixmap()
{
    if( p.isNull() )
        createBarcode( &p, KApplication::desktop() );

    if( p.isNull() ) {
        KMessageBox::error( 0, "<qt>" + i18n("Barcode not valid!") + "<br>" + barcode.value + "</qt>" );
        barcode.valid = false;
    }
        
    return p;
}

bool BarCode::createPixmap( TQPixmap* target, int resx, int resy )
{
    KTempFile* output = new KTempFile( TQString(), ".ps" );;
    output->file()->close();
    
    KTempFile* input = new KTempFile( TQString(), ".pbm" );
    input->file()->close();

    m_value = createSequence( barcode.value );

    if( BarCode::hasFeature( barcode.type, PDF417 ) ) {
        if(!createPdf417( output )) {
            cleanUp( output, input, target );
            return false;
        }
    } else if( BarCode::hasFeature( barcode.type, TBARCODE ) ) {
        if(!createTBarcode( output )) {
            cleanUp( output, input, target );
            return false;
        }
    } else { // if( BarCode::hasFeature( barcode.type, GNU_BARCODE ) ) {
        TQString flag = barcode.text ? "" : "-n";

        KShellProcess proc;
        proc << "barcode" << "-E"
             << "-b" << KShellProcess::quote( m_value ) << flag
             << "-e" << barcode.type << "-o" << output->name();

        proc.start( KProcess::Block, KProcess::NoCommunication );
        proc.resume();

        if( proc.exitStatus() ) {
            cleanUp( output, input, target );
            return false;
        }
    }

    TQFileInfo fi( output->name() );
    // if file size = 0, error in generation
    if( !fi.size() ) {
        cleanUp( output, input, target );
        return false;
    }

    TQSize s = getBoundingBox( output->name() );
    double sw = (double)s.width()/72 * resx;
    double sh = (double)s.height()/72 * resy;
    
    KShellProcess proc2;
    proc2 << "gs" << TQString("-g%1x%2").arg(int(sw*(double)barcode.scale)).arg(int(sh*(double)barcode.scale))
          << "-r" + TQString::number( resx*(double)barcode.scale ) + "x" + TQString::number( resy*(double)barcode.scale )
          << "-sDEVICE=pbmraw" << "-sOutputFile=" + input->name() << "-sNOPAUSE"
          << "-q " + output->name() << "-c showpage" << "-c quit";
    
    proc2.start( KProcess::Block, KProcess::NoCommunication );
    proc2.resume();

    if( proc2.exitStatus() ) {
        cleanUp( output, input, target );
        return false;
    }

    target->load( input->name(), "PBM" );
//    BarcodeCache::instance()->write( barcode, resx, resy, target, m_value );

    input->unlink();
    output->unlink();

    delete output;
    delete input;

    return true;
}

void BarCode::createBarcode( TQPixmap* target, TQPaintDevice* device )
{
    TQPaintDeviceMetrics pdm( device );
    int resx = pdm.logicalDpiX();
    int resy = pdm.logicalDpiY();

    TQString value = createSequence( barcode.value );
    TQPixmap* cached = 0;//BarcodeCache::instance()->read( barcode, resx, resy, value );

    // no matching barcode found in cache
    if( !cached ) {
        if( !createPixmap( target, resx, resy ) )
            return;
    } else {
        *target = *cached;
        delete cached;
    }
    
    if( BarCode::hasFeature( barcode.type, PDF417 ) ) {
        // we have to scale to the correct resolution.
        // we scale already here and not at the end,
        // so that the addMargin function does not get a scaled margin.
        TQPaintDeviceMetrics pdm( KApplication::desktop() );
        int screenresx = pdm.logicalDpiX();
        int screenresy = pdm.logicalDpiY();
    
        TQWMatrix m;
        double scalex = (resx/screenresx)*barcode.scale;
        double scaley = (resy/screenresy)*barcode.scale;
        m.scale( scalex, scaley );
        *target = target->xForm( m );
    }
    *target = cut( target, barcode.cut );
    *target = addMargin( target, barcode.margin );

    // Rotate
    TQWMatrix m;
    m.rotate( (double)barcode.rotation );
    *target = target->xForm( m );

    barcode.valid = true;
}

bool BarCode::createPdf417( KTempFile* output )
{
    KTempFile text( TQString(), ".txt" );
    TQTextStream t( text.file() );
    t << m_value;
    text.file()->close();

    // ps does not work use pbm!
    KShellProcess proc;
    proc << "pdf417_enc" << "-tps" << text.name() << output->name()
         << barcode.pdf417.row
         << barcode.pdf417.col
         << barcode.pdf417.err;
         
    proc.start( KProcess::Block, KProcess::NoCommunication );
    proc.resume();

    if( proc.exitStatus() ) {
        text.unlink();
        return false;
    }

    text.unlink();    
    return true;    
}

bool BarCode::createTBarcode( KTempFile* output )
{
    // print text
    TQString flag = barcode.text ? "" : "n";
    // escape text
    flag.append( barcode.tbarcode.escape ? " son" : " soff" );
    // autocorrection
    flag.append( barcode.tbarcode.autocorrect ? " Aon" : " Aoff" );
    // text above
    flag.append( barcode.tbarcode.above ? " a" : "" );
    
    KShellProcess proc;
    proc << "tbarcodeclient" << "-f" + output->name();
    if( !BarCode::hasFeature( barcode.type, BARCODE2D ) )
        proc << TQString( "m%1" ).arg( barcode.tbarcode.modulewidth * 1000 );

    if( BarCode::hasFeature( barcode.type, DATAMATRIX ) ) 
        proc << TQString( "Ds%1" ).arg( barcode.datamatrix.size );

    if( BarCode::hasFeature( barcode.type, PDF417BARCODE ) )
        proc << TQString( "Pr%1 Pc%2 Pe%3" ).arg( barcode.pdf417.row )
                                           .arg( barcode.pdf417.col )
                                           .arg( barcode.pdf417.err );
        
    proc << barcode.type << "tPS" << TQString("c%1").arg( barcode.tbarcode.checksum ) << flag << "d" + KShellProcess::quote(  m_value );
    proc.start( KProcess::Block, KProcess::NoCommunication );
    proc.resume();

    if( proc.exitStatus() )
        return false;

    return true;
}

const TQPixmap BarCode::printerPixmap( TQPaintDevice* device )
{
    if( pp.isNull() )
        createBarcode( &pp, device );
    
    return pp;
}

void BarCode::fillDefault( barcodeData* data )
{
    data->margin = 10;
    data->text = true;
    data->value = "1234567890";
    data->type = "code39";
    data->scale = 1.0;
    data->cut = 1.0;
    data->rotation = 0;
    data->valid = false;

    data->pdf417.row = 24;
    data->pdf417.col = 8;
    data->pdf417.err = 5;

    data->datamatrix.size = 0;

    data->tbarcode.modulewidth = 0.353;
    data->tbarcode.escape = false;
    data->tbarcode.above = false;
    data->tbarcode.autocorrect = false;
    data->tbarcode.checksum = 0;
        
    data->xml.caption = "Static";
    data->xml.x = 0;
    data->xml.y = 0;

    data->sequence.enabled = false;
    data->sequence.mode = NUM;
    data->sequence.step = 1;
    data->sequence.start = 1;
}

void BarCode::redrawBarcode()
{
    p.resize( 0, 0 );
    pp.resize( 0, 0 );
}

TQPixmap BarCode::cut( TQPixmap* pic, double cut)
{
    if( cut == 1.0 )
        return (*pic);

    TQPixmap pcut( pic->width(), int((double)pic->height() * cut) );
    pcut.fill( TQt::white ); // barcode.bg

    TQWMatrix m;
    /*
     * if text is above the barcode cut from
     * below the barcode.
     */

    // TODO: put this into one if, I am to stupid today.....
    if( BarCode::hasFeature( barcode.type, TBARCODEADV ) ) {
        if( !barcode.tbarcode.above )
            m.rotate( 180 );
    } else
        m.rotate( 180 );

    TQPainter painter( &pcut );
    painter.drawPixmap( 0, 0, pic->xForm( m ) );

    return pcut.xForm( m );
}

TQPixmap BarCode::addMargin( TQPixmap* pic, int margin )
{
    TQPixmap p;

    /* We have to handle UPC special because of the checksum character
     * which is printed on the right margin.
     * The samve goes for ISBN codes.
     * Any other formats??
     */

    bool gnubarcode = BarCode::hasFeature( barcode.type, GNU_BARCODE );
    double barm = gnubarcode ? BARCODE_MARGIN * barcode.scale : 0;

    // Add margin
    double sx = barm;
    double sy = barm;
    double sw = pic->width() - barm * 2;
    double sh = pic->height() - barm * 2;

    if( gnubarcode && (barcode.type == "upc" || barcode.type == "isbn") ) {
        sw = pic->width() - barm;

        p.resize( pic->width() + int(margin*2 - barm), pic->height() + int(margin * 2 - barm * 2) );
    } else
        p.resize( pic->width() + int(margin*2 - barm * 2), pic->height() + int(margin * 2 - barm * 2) );

    p.fill( TQt::white ); // barcode.bg
    TQPainter painter( &p );
    painter.drawPixmap( margin, margin, *pic, (int)sx, (int)sy, (int)sw, (int)sh );
    painter.end();

    return p;
}

const TQString BarCode::getMaxLength( const TQString & name )
{
    TQSqlQuery query("select uid, (length(barcode_no)) as LEN from " TABLE_BASIC
        " where encoding_type = '" + name +"' ORDER by LEN DESC LIMIT 1" );

    while( query.next() ) {
        TQSqlQuery queryuid("select barcode_no from barcode_basic where uid = '"
            + query.value( 0 ).toString() + "'" );
        while( queryuid.next() )
            if(!queryuid.value( 0 ).toString().isEmpty())
                return queryuid.value( 0 ).toString();
    }

    TQSqlQuery query1("select uid, (length(barcode_no)) as LEN from " TABLE_CUSTOMER_TEXT 
                    " where encoding_type = '" + name +"' ORDER by LEN DESC LIMIT 1" );

    while( query1.next() ) {
        TQSqlQuery queryuid("select barcode_no from customer_text where uid = '"
            + query1.value( 0 ).toString() + "'" );
        while( queryuid.next() )
            if(!queryuid.value( 0 ).toString().isEmpty())
                return queryuid.value( 0 ).toString();
    }

    return "1234567";        
}

void BarCode::cleanUp( KTempFile* file, KTempFile* file2, TQPixmap* target )
{
    target->resize( 0, 0 );

    file->unlink();
    file2->unlink();
    delete file;
    delete file2;
}

TQString BarCode::createSequence( const TQString & value )
{
    if( !barcode.sequence.enabled )
        return value;
        
    if( value.contains( '#' ) <= 0 )
        return value;

    TQString text = value;
    int pos = 0, counter = 1;

    pos = text.find("#", pos);
    pos++;
    while( text[pos] == '#' ) {
        text.remove(pos, 1);
        counter++;
    }

    pos = text.find("#", 0);
    TQString temp;

    if( barcode.sequence.mode == NUM ) {
        int v = barcode.sequence.start + m_index*barcode.sequence.step;
        temp.sprintf("%0*i", counter, v );
    } else {
        for( int i = 0; i < counter; i++ )
            temp.append( "A" );

        unsigned int z = 0;
        for( int p = temp.length(); p >= 0; p--, z++ ) {
            if( barcode.sequence.mode == ALPHA ) {
                int v = 'A' + m_index*barcode.sequence.step;
                v -= z*('Z'-'A');
            
                if( v <= 'Z' ) {
                    temp[p] = TQChar(v);                        
                    break;
                } else if( v > 'Z' )
                    v = 'Z';
                temp[p] = TQChar(v);            
            } else if( barcode.sequence.mode == ALPHANUM ) {
                tqDebug("NOT IMPLEMENTED");
/*                char array[36];
                for( unsigned int i = 'A'; i <= 'Z'; i++ )
                    array[i-'A'] = i;
                for( unsigned int i = '0'; i <= '9'; i++ )
                    array['Z'-'A'+i-'0'] = i;

                int z = m_index*barcode.sequence.step;
                if( z < sizeof(array) )
                    temp[]
                int v = array[ ]*/
            }
        }
    }
    
    text.replace( pos, 1, temp);

    return text;
}

TQString BarCode::sequenceValue()
{
    return createSequence( barcode.value );
}

bool BarCode::hasFeature( const TQString & type, unsigned int feature )
{
    for( unsigned int i = 0; i < codes.count(); i++ )
        if( codes[i].name == type )
            return (codes[i].features & feature) == feature;
            
    return false;
}

TQSize BarCode::getBoundingBox( const TQString & filename )
{ 
    TQSize s(0,0);
    TQFile f( filename );
    if( !f.open( IO_ReadOnly ) )
        return s;
        
    TQString t;
    while( f.readLine( t, 1000 ) != -1 )
    {
        if( t.startsWith( "%%BoundingBox:") )
        {
            int x = 0;
            int y = 0;
            int w = 0;
            int h = 0;
            t = t.right( t.length() - 14 );
            sscanf( (const char*)t, "%d %d %d %d", &x, &y, &w, &h );
            s = TQSize( w, h );
            break;
        }
    }

    f.close();
    return s;
}

bool BarCode::m_haveGnuBarcode = false;
bool BarCode::m_havePdfEncode = false;
bool BarCode::m_haveTBarcode = false;

barcodeFormat BarCode::fillStruct( const TQString & name, const TQString & text, const int feature )
{
    barcodeFormat t;
    t.name = name;
    t.text = text;
    t.features = feature;
    return t;
}

void BarCode::setHaveBarcode()
{
    m_haveGnuBarcode = !KStandardDirs::findExe( "barcode" ).isNull();
    m_havePdfEncode = !KStandardDirs::findExe( "pdf417_enc" ).isNull();
    m_haveTBarcode = !KStandardDirs::findExe( "tbarcodeclient" ).isNull();

    if( codes.count() == 0 ) {
        if( m_haveGnuBarcode ) {
            codes.append( fillStruct( "ean", i18n("EAN (EAN 8 or EAN 13)"), GNU_BARCODE ) );
            codes.append( fillStruct( "upc", i18n("UPC (12-digit EAN; UPCA and UPCB)"), GNU_BARCODE ) );
            codes.append( fillStruct( "isbn", i18n("ISBN (still EAN13)"), GNU_BARCODE | NOCUT  ) );
            codes.append( fillStruct( "code39", i18n("Code 39"), GNU_BARCODE ) );
            codes.append( fillStruct( "code39 -c", i18n("Code 39 (no checksum)"), GNU_BARCODE ) );
            codes.append( fillStruct( "code128", i18n("Code 128 (a,b,c: autoselection)"), GNU_BARCODE ) );
            codes.append( fillStruct( "code128c", i18n("Code 128C (compact form digits)"), GNU_BARCODE ) );
            codes.append( fillStruct( "code128b", i18n("Code 128B, full printable ascii"), GNU_BARCODE ) );
            codes.append( fillStruct( "i25", i18n("interleaved 2 of 5 (only digits)"), GNU_BARCODE ) );
            codes.append( fillStruct( "i25 -c", i18n("interleaved 2 of 5 (only digits, no checksum)"), GNU_BARCODE ) );
            codes.append( fillStruct( "128raw", i18n("Raw code 128"), GNU_BARCODE ) );
            codes.append( fillStruct( "cbr", i18n("Codabar"), GNU_BARCODE ) );
            codes.append( fillStruct( "cbr -c", i18n("Codabar (no checksum)"), GNU_BARCODE ) );            
            codes.append( fillStruct( "msi", i18n("MSI"), GNU_BARCODE ) );
            codes.append( fillStruct( "pls", i18n("Plessey"), GNU_BARCODE ) );
            codes.append( fillStruct( "code93", i18n("Code 93"), GNU_BARCODE ) );
        }

        if( m_havePdfEncode ) {
            codes.append( fillStruct( "pdf417", i18n("pdf 417 2D Barcode"), BARCODE2D | PDF417 | PDF417BARCODE ) );
        }
 
        if( m_haveTBarcode ) {
            codes.append( fillStruct( "b1", "Code 11", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
            codes.append( fillStruct( "b2", "Code 2 of 5 (Standard)", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
            codes.append( fillStruct( "b3", "Interleaved 2 of 5 Standard", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b4", "Code 2 of 5 IATA", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
            codes.append( fillStruct( "b5", "Code 2 of 5 Matrix", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
            codes.append( fillStruct( "b6", "Code 2 of 5 Data Logic", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
            codes.append( fillStruct( "b7", "Code 2 of 5 Industrial", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
            codes.append( fillStruct( "b8", "Code 3 of 9 (Code 39)", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
            codes.append( fillStruct( "b9", "Code 3 of 9 (Code 39) ASCII", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
            codes.append( fillStruct( "b10", "EAN8", TBARCODE | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) );
            codes.append( fillStruct( "b11", "EAN8 - 2 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) );
            codes.append( fillStruct( "b12", "EAN8 - 5 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN8CHECK | MODULO10CHECK ) );
            codes.append( fillStruct( "b13", "EAN13", TBARCODE | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) );
            codes.append( fillStruct( "b14", "EAN13 - 2 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) );
            codes.append( fillStruct( "b15", "EAN13 - 5 digits add on", TBARCODE | NOCUT | TBARCODEADV | EAN13CHECK | MODULO10CHECK ) );
            codes.append( fillStruct( "b16", "EAN128 (supports AIS)", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
            codes.append( fillStruct( "b17", "UPC 12 Digits", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
            codes.append( fillStruct( "b18", "CodaBar (2 width)", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
            codes.append( fillStruct( "b19", "CodaBar (18 widths)", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b20", "Code128", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b21", "Deutsche Post Leitcode", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b22", "Deutsche Post Identcode", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b25", "Code 93", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b26", "Identical to eBC_UPCA", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b33", "UCC128 (= EAN128)", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b34", "UPC A", TBARCODE | TBARCODEADV | TBARCODEADV | UPCACHECK ) );
            codes.append( fillStruct( "b35", "UPC A - 2 digit add on", TBARCODE | TBARCODEADV | UPCACHECK ) );
            codes.append( fillStruct( "b36", "UPC A - 5 digit add on", TBARCODE | TBARCODEADV | UPCACHECK ) );
            codes.append( fillStruct( "b37", "UPC E", TBARCODE | TBARCODEADV | UPCECHECK ) );
            codes.append( fillStruct( "b38", "UPC E - 2 digit add on", TBARCODE | TBARCODEADV | UPCECHECK ) );
            codes.append( fillStruct( "b39", "UPC E - 5 digit add on", TBARCODE | TBARCODEADV | UPCECHECK ) );
            codes.append( fillStruct( "b40", "PostNet ZIP (5d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
            codes.append( fillStruct( "b41", "PostNet ZIP (5d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
            codes.append( fillStruct( "b42", "PostNet ZIP (8d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
            codes.append( fillStruct( "b43", "PostNet ZIP+4 (5d.+4d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
            codes.append( fillStruct( "b44", "PostNet DPBC (5d.+4d.+2d.)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
            codes.append( fillStruct( "b45", "PostNet DPBC (5d.+4d.+2d.+CD)", TBARCODE | NOCUT | TBARCODEADV | POSTNETCHECK ) );
            codes.append( fillStruct( "b46", "Plessey Code", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b47", "MSI Code", TBARCODE | TBARCODEADV | MODULO10CHECK ) );
            codes.append( fillStruct( "b50", "LOGMARS", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
            codes.append( fillStruct( "b55", "PDF417 - 2D bar code", TBARCODE | BARCODE2D | PDF417BARCODE ) );
            codes.append( fillStruct( "b56", "PDF417 Truncated - 2D bar code", TBARCODE | BARCODE2D | PDF417BARCODE ) );
            codes.append( fillStruct( "b57", "MaxiCode - 2D-bar code (Postscript only)", TBARCODE | BARCODE2D ) );
            codes.append( fillStruct( "b58", "QR-Code", TBARCODE | BARCODE2D ) );
            codes.append( fillStruct( "b59", "Code128 (CharSet A)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) );
            codes.append( fillStruct( "b60", "Code128 (CharSet B)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) );
            codes.append( fillStruct( "b61", "Code128 (CharSet C)", TBARCODE | TBARCODEADV | CODE128CHECK | MODULOALLCHECK ) );
            codes.append( fillStruct( "b62", "Code 93 Ascii", TBARCODE | TBARCODEADV | MODULOALLCHECK ) );
            codes.append( fillStruct( "b63", "Australian Post Standard Customer", TBARCODE | NOCUT | TBARCODEADV ) );
            codes.append( fillStruct( "b64", "Australian Post Customer 2", TBARCODE | NOCUT | TBARCODEADV ) );
            codes.append( fillStruct( "b65", "Australian Post Customer 3", TBARCODE | NOCUT | TBARCODEADV ) );
            codes.append( fillStruct( "b66", "Australian Post Reply Paid", TBARCODE | NOCUT | TBARCODEADV ) );
            codes.append( fillStruct( "b67", "Australian Post Routing", TBARCODE | NOCUT | TBARCODEADV ) );
            codes.append( fillStruct( "b68", "Australian Post Redirection", TBARCODE | NOCUT | TBARCODEADV ) );
            codes.append( fillStruct( "b69", "ISBN Code (=EAN13P5)", TBARCODE | TBARCODEADV ) );
            codes.append( fillStruct( "b70", "Royal Mail 4 State (RM4SCC)", TBARCODE | NOCUT | TBARCODEADV ) );
            codes.append( fillStruct( "b71", "Data Matrix", DATAMATRIX | TBARCODE | BARCODE2D | NOSCALE ) );
        }
    }
}