On this page
If you have ever worked with pharmaceutical products, you have probably aimed a scanner at a barcode and seen nothing happen. You try again. You bring the phone a bit nearer, then a bit farther away, adjust the angle, perhaps switch on the flashlight, and then the barcode scans as if nothing had ever gone wrong.
The first reaction is usually to blame the barcode: it looks too small, the printing may be unclear, or the packaging may be flawed. The truth is a little more nuanced. Barcode scanning can be difficult in pharmaceutical settings for a variety of reasons, and the barcode is only one of them.
Small Codes Carrying a Lot of Data
Pharmaceutical packaging is a good illustration of how difficult real-world barcode scanning can be. A lot of information must fit into a very small space. In addition to the product name, dosage, manufacturer details, warnings, batch details and expiration date, there is a barcode with crucial information somewhere on that comparatively small package.
This is one of the reasons why GS1 DataMatrix has become so important in pharmaceutical applications. A DataMatrix can store a significant amount of information while taking up relatively little physical space, which is extremely useful on small medicine packages. The smaller the barcode becomes, however, the more demanding the scanning process can be.
A barcode that looks perfectly readable to a person can still be hard for a camera and decoding engine. When a DataMatrix's individual modules are small, the camera must capture enough detail to tell them apart accurately. If the image is slightly blurry, the lighting is bad or the barcode is too far away, the scanner's job becomes much more difficult.
Packaging That Works Against the Camera
Pharmaceutical packaging doesn't simplify matters either. Some products are packaged in bottles, while others arrive in small cardboard boxes. Some surfaces are curved or uneven, others are glossy and reflective. When you point a phone at a shiny package with a flawlessly printed barcode, the light can reflect straight into the camera: the barcode is there and the camera sees it, yet it still cannot decode it correctly.
In these situations people often believe that a better camera will solve the issue on its own. It can help at times, but camera megapixels aren't the whole picture. What matters most is the device's ability to capture the barcode, the speed at which the image is processed, and how the decoding engine performs when the barcode isn't presented in ideal conditions.
Build for the Barcode People Actually Scan

This is one of the areas where barKoder is designed to help. Instead of treating barcode scanning as simply a matter of recognizing a pattern, the SDK is built to handle practical scanning situations where speed and reliability matter.
Speed becomes particularly important in pharma. When a pharmacist scans a single package, a short delay might not seem like much. A warehouse worker, however, scans hundreds or thousands of products over the course of a shift, and those small delays quickly add up.
Reading the Data Inside the Barcode
The same holds true when an application needs more than the barcode value. Pharmaceutical barcodes can encode a variety of information, including the GTIN, serial number, batch or lot number, and expiration date. The application may need to extract and work with those separate pieces of data rather than simply returning a single, long string.
Between pointing the camera and seeing the result, five things happen:
- The camera takes the picture.
- The SDK finds the barcode in it.
- The decoder processes the barcode.
- The application receives the result.
- The system managing the product interprets and uses the data.
When everything works, the user doesn't think about any of this: they point the camera at the package and move on.
Enable Only the Barcode Types You Need
Another small detail can make a surprisingly big difference when you develop a barcode-scanning application: don't enable every barcode symbology just because the SDK supports it.
If your pharmaceutical application is designed around a specific set of barcode types, configure the scanner around those requirements. If you know that your workflow primarily uses GS1 DataMatrix, for example, there is little reason to make the scanning engine search through every possible barcode format at the same time. The more specific you can be about what your application is looking for, the more focused the scanning experience can become.
This is especially useful when several different codes are printed on the same package. A medicine box can contain multiple symbols, numbers and pieces of text, and the application needs to know which information actually matters.
Medicines and their shipments mostly carry a handful of barcode types:
Barcode | Where it appears |
|---|---|
GS1 DataMatrix | The unique identifier on each pack: GTIN, serial number, batch and expiry date (required by the EU Falsified Medicines Directive and the US DSCSA) |
EAN-13 / UPC-A | The retail barcode on the pack, scanned at the pharmacy counter; in the US the UPC-A carries the NDC |
Code 128 (GS1-128) | Cases and pallets in distribution |
Code 32 (Italian Pharmacode) | Medicines sold in Italy |
QR Code | Some packs, linking to patient information or a product page |
A pharmacy app that checks packs could switch on GS1 DataMatrix, EAN-13, UPC-A and QR Code and leave every other type off. In barKoder this is a few lines when you set up the scanner, and the scanner reads only the types you switch on. On Android:
bkdView.config.decoderConfig.SetEnabledDecoders(
arrayOf(
Barkoder.DecoderType.Datamatrix,
Barkoder.DecoderType.Ean13,
Barkoder.DecoderType.UpcA,
Barkoder.DecoderType.QR
)
)On iOS:
guard let decoderConfig = barkoderView.config?.decoderConfig
else { return }
decoderConfig.datamatrix.enabled = true
decoderConfig.ean13.enabled = true
decoderConfig.upcA.enabled = true
decoderConfig.qr.enabled = trueIn the browser, with the Web SDK:
Barkoder.setEnabledDecoders(
Barkoder.constants.Decoders.Datamatrix,
Barkoder.constants.Decoders.Ean13,
Barkoder.constants.Decoders.UpcA,
Barkoder.constants.Decoders.QR
);In Flutter and React Native each type is switched on with setBarcodeTypeEnabled, for example setBarcodeTypeEnabled(BarcodeType.datamatrix, true). An app for the Italian market adds Code 32 (Code32, or code32 on iOS), and one that also receives shipments adds Code 128. The full list of types for each platform is in the barKoder documentation.
Why a Pharma Barcode Might Not Scan
Pharmaceutical barcode scanning is more complicated than it first appears. From the outside it looks simple: there is a barcode on a box, you point a camera at it, and you get the result. Underneath that simple interaction is a combination of image capture, barcode detection, decoding, data parsing and application logic, and every part of that chain can affect the final experience.
So the next time a pharmaceutical barcode doesn't scan, the barcode itself may not be the problem. The cause can be on the pack or in the scan:
Light reflects off the surface.
The barcode was printed with flaws.
The device is moving.
The scanning engine isn't optimized for the situation.
What Good Barcode Scanning Should Feel Like
For developers creating pharmaceutical applications, the goal is not just to make a barcode scan in ideal lab conditions. The goal is to make it work when a real person holds a real product in a real setting.
The best scanning experience is one in which no one is even aware of the underlying technology.
Frequently asked questions
Why don't pharmaceutical barcodes always scan correctly?
Pharmaceutical barcodes can be difficult to scan because they are often very small and may be printed on reflective, curved, or uneven surfaces. Poor lighting, motion, image blur, printing imperfections, and the distance or angle of the camera can also affect scanning performance.
Why is GS1 DataMatrix commonly used on pharmaceutical packaging?
GS1 DataMatrix can store important information such as a GTIN, serial number, batch or lot number, and expiration date in a relatively small space. This makes it well suited to pharmaceutical packaging, where space is often limited.
Does a higher-megapixel camera guarantee better barcode scanning?
Not necessarily. Camera resolution is only one factor. Reliable barcode scanning also depends on image quality, lighting, focus, motion, barcode size, and the capabilities of the decoding engine. A well-optimized scanning SDK can often make a significant difference in real-world conditions.
How can developers improve pharmaceutical barcode scanning performance?
Developers can improve performance by optimizing the scanning experience for the barcode types used in their application, ensuring the SDK handles difficult image conditions, and avoiding unnecessary barcode symbologies when they are not required. For pharma applications, support for GS1 DataMatrix and data parsing can also be important.
What information can be extracted from a pharmaceutical barcode?
Depending on the barcode and GS1 data structure, pharmaceutical barcodes can contain information such as the Global Trade Item Number (GTIN), serial number, batch or lot number, and expiration date. A capable barcode SDK can decode and parse these individual data elements for use within the application.



