6 int main(int argc, char **argv)
8 int ps = 1, pcl = 0, oflags;
9 if (argc == 2 && !strcmp(argv[1],"-P")) {
10 ps = 0; pcl = 1; argc=1;
13 fprintf(stderr, "%s: use \"%s\" for postscript or \"%s -P\" for PCL\n",
14 argv[0], argv[0], argv[0]);
18 oflags = BARCODE_OUT_PCL;
20 oflags = BARCODE_OUT_PS | BARCODE_OUT_NOHEADERS;
21 printf("%%!PS-Adobe-2.0\n");
22 printf("%%%%Creator: barcode sample program\n");
23 printf("%%%%EndComments\n");
24 printf("%%%%EndProlog\n\n");
25 printf("%%%%Page: 1 1\n\n");
27 /* Print a few barcodes in several places in the page */
29 /* default size, bottom left */
30 Barcode_Encode_and_Print("800894002700",stdout, 0, 0, 40, 40,
31 BARCODE_EAN | oflags);
34 Barcode_Encode_and_Print("800894002700",stdout, 70, 50, 160, 55,
35 BARCODE_EAN | oflags);
38 Barcode_Encode_and_Print("800894002700",stdout, 40, 30, 270, 70,
39 BARCODE_EAN | oflags);
42 Barcode_Encode_and_Print("000000000000",stdout, 170, 0, 40, 160,
43 BARCODE_EAN | oflags);
45 /* Still bigger all-0 (but UPC, this time) */
46 Barcode_Encode_and_Print("00000000000",stdout, 250, 0, 270, 160,
47 BARCODE_UPC | oflags);
49 /* A few code-39 ones */
50 Barcode_Encode_and_Print("silly code",stdout, 0, 0, 40, 320,
52 Barcode_Encode_and_Print("SAMPLE CODES",stdout, 100, 30, 400, 80,
56 Barcode_Encode_and_Print("1-56592-292-1 90000",stdout, 0, 0, 40, 430,
57 BARCODE_ISBN | oflags);
60 Barcode_Encode_and_Print("07447084452 07",stdout, 0, 0, 300, 410,
61 BARCODE_UPC | oflags);
64 Barcode_Encode_and_Print("12345678900123456789",stdout, 0, 0, 40, 530,
65 BARCODE_128C | oflags);
67 /* and my data as code-128B autodetected */
68 Barcode_Encode_and_Print("RBNLSN68T11E897W",stdout, 0, 60, 240, 510,
70 /* same as code-39, forced */
71 Barcode_Encode_and_Print("RBNLSN68T11E897W",stdout, 0, 60, 240, 590,
72 BARCODE_NO_CHECKSUM | BARCODE_39 | oflags);
74 /* one interleaved 2 of 5 */
75 Barcode_Encode_and_Print("0123456789",stdout, 0, 0, 40, 620,
76 BARCODE_I25 | oflags);
78 /* upc-e and ean-8 (autotected based on code size) */
79 Barcode_Encode_and_Print("012345",stdout, 0, 0, 50, 720, oflags);
80 Barcode_Encode_and_Print("0123456",stdout, 0, 0, 160, 720, oflags);
87 printf("\nshowpage\n");
88 printf("%%%%Trailer\n\n");