A barcode is a set of lines which contain machine-readable data – run a barcode reader over them and you can access some interesting information (so it is a bit like a sort of braille for machines). As barcodes are very useful and PDF files are very common, it is not surprising that we see quite a few barcodes in PDF files. The interesting thing is that there is no standard way to put a barcode inside a PDF. So here are the different ways we have seen…
Bar code as an image
This is the most common way to do it. The barcode is turned into a single bit-map or vector image and embedded in the PDF.
Barcode as text
A special font is used to show the barcode and a text string is drawn in the PDF file, using the barcode font.
Barcode as a form object
The barcode is added as an annotion which may be text or an image.
Barcode as embbed images
The barcode is added as a set of embedded lines (black or white). When all drawn, the images produce the full barcode.
So while the barcodes may look identical, different PDF creation tools add the barcode in very different ways and will give very different results if you try to extract them.
Do you have any other examples to add to my list?
This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!
IDRsolutions develop a Java PDF library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.