How do barcodes appear inside a PDF file

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!

Related Posts:

  • No Related Posts
The following two tabs change content below.

Mark Stephens

System Architect and Lead Developer at IDRSolutions
Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.
Markee174

About Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>