RubyPDF Blog PDF Barcode to PDF–Let Zint Support PDF output

Barcode to PDF–Let Zint Support PDF output

We can convert a barcode to PDF in these ways,

  • converting a barcode image to PDF, easy, but has resolution issue
  • using a barcode font, the font is not easy to find
  • directly printing a barcode to PDF, is much smaller and no resolution issue.

I have talked about Zint recently, Zint shared library Change License From GPL to BSD.

Zint is very powerful, it supports 150 format barcode, and supports png, bitmap, svg and eps output, but no PDF. So I decide to let it support PDF output, though I am not familiar with C/C++.

After some research, I decide to use Libharu, because of,

  • Open Source and under the ZLIB/LIBPNG License, similar with libzint(BSD 3 License)
  • Cross platform, Windows, Linux, Mac OS X, Android, IOS(iPhone/iPad) and so on.
  • All code is written in C(ANSI-C),
  • Only optionally depends on zlib and libpng, same as libzint(aka zint library)
  • Has well-document API and enough demo code

At beginning, I referred to svg.c, after the job done,  and ouput a PDF, I noticed I made a big mistake, the origin of the PDF coordinate system (0, 0) represents the bottom-left corner of the PDF page , it different with svg or image, but same as PS/EPS, so I had to rewrite it completely, and this time I referred to ps.c, finally I got what I want.

Some PDF and PNG output examples,

ean13

ean13 zint -o ean13.pdf -b 13 -d 471350701429

isbn13

isbn13 zint -o isbn13.pdf -b 69 -d “9780201483406”

code39

code39 zint -o code39.pdf -b 8 -d “RUBYPDF TECH”

qrcode

qrcode zint -o qrcode.pdf -b 58 -d “https://blog.rubypdf.com”

pdf417

PDF417 zint -o PDF417.pdf -b 55 -d “RUBYPDF TECH”

code128

code 128 zint -o 128.pdf -d “RUBYPDF TECH”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.