Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zint/extras/zebu_pdf.c @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * zebu_pdf.c | |
| 3 * | |
| 4 * This code uses Zint to encode data into a PDF417 and then outputs | |
| 5 * the symbol as text suitable for use with Code PDF417 font by | |
| 6 * Grand Zebu. | |
| 7 * | |
| 8 * This code can be compiled with: | |
| 9 * | |
| 10 * gcc -o zebu_pdf zebu_pdf.c -lzint | |
| 11 * | |
| 12 * Grand Zebu's font can be downloaded from: | |
| 13 * | |
| 14 * https://grandzebu.net/informatique/codbar-en/pdf417.htm | |
| 15 * | |
| 16 */ | |
| 17 | |
| 18 #include <stdio.h> | |
| 19 #include <zint.h> | |
| 20 #include <string.h> | |
| 21 int main(int argc, char **argv) | |
| 22 { | |
| 23 struct zint_symbol *my_symbol; | |
| 24 int error = 0; | |
| 25 int x, y, sub, glyph, group; | |
| 26 | |
| 27 my_symbol = ZBarcode_Create(); | |
| 28 | |
| 29 my_symbol->symbology = BARCODE_PDF417; | |
| 30 my_symbol->output_options = OUT_BUFFER_INTERMEDIATE; | |
| 31 | |
| 32 error = ZBarcode_Encode(my_symbol, argv[1], strlen(argv[1])); | |
| 33 if (error != 0) | |
| 34 { | |
| 35 printf("%s\n", my_symbol->errtxt); | |
| 36 } | |
| 37 if (error >= ZINT_ERROR_TOO_LONG) | |
| 38 { | |
| 39 ZBarcode_Delete(my_symbol); | |
| 40 return 1; | |
| 41 } | |
| 42 | |
| 43 for (y = 0; y < my_symbol->rows; y++) { | |
| 44 printf("+*"); | |
| 45 sub = 0; | |
| 46 glyph = 0; | |
| 47 group = 0; | |
| 48 for (x = 18; x < my_symbol->width - 19; x++) { | |
| 49 glyph *= 2; | |
| 50 if ((my_symbol->encoded_data[y][x / 8] >> (x % 8)) & 1) { | |
| 51 glyph++; | |
| 52 } | |
| 53 sub++; | |
| 54 if (sub == 5) { | |
| 55 if (glyph <= 5) { | |
| 56 printf("%c", glyph + 'A'); | |
| 57 } else { | |
| 58 printf("%c", (glyph - 6) + 'a'); | |
| 59 } | |
| 60 glyph = 0; | |
| 61 sub = 0; | |
| 62 group++; | |
| 63 } | |
| 64 if (group == 3) { | |
| 65 printf("*"); | |
| 66 x += 2; | |
| 67 group = 0; | |
| 68 } | |
| 69 } | |
| 70 printf("-\n"); | |
| 71 } | |
| 72 | |
| 73 ZBarcode_Delete(my_symbol); | |
| 74 return 0; | |
| 75 } |
