Encoding Special Characters

In many cases, our users may need to insert special characters like carriage returns and functions into their barcodes. Each symbology’s ISO standards dictate which characters can be encoded into a barcode and these characters are outlined on our website under each symbology’s respective user manual page. For a step-by-step guide to choosing the correct type of barcode for your project, have a look at our previous post, Choosing the Right Barcode.


How to Insert Special Characters with ASCII Codes


Many special characters can be encoded using Barcode Bakery simply by using PHP’s chr function. The decimal code associated with each special character can be located using an ASCII table and then passed to the function. For example, to insert a carriage return, you’ll want to use chr(13) as follows:

$code->parse(“hello” . chr(13) . “new line”);


This use of the carriage return is useful when a barcode will be scanned to populate a single-input multi-line form such as a text area. If a tab character is required, such as when a barcode will be scanned to populate a form with multiple text inputs, then chr(9) would be used.


How to Insert FNC1 with setTilde()


For certain symbologies such as DataMatrix that allow the FNC1 character, the setTilde() method should be used. By setting its value to true, the tilde character can then be used to insert FNC1 by inserting ~F  into a string. This character is used in most cases to enter a different mode specific to each barcode type.


To find more information about which barcode symbologies can accommodate the special characters you require, check out our user guides in the resources found on our website: http://www.barcodebakery.com/en/resources

Create Barcodes Using ASP.NET

BarcodeASP.com has recently been updated to provide even more of the popular barcode symbologies already found on BarcodePHP.com. We offer the leading barcode generation software for ASP.NET. The code we have developed can be implemented and modified to suit almost any barcoding need. Our website provides ample resources in the form of manuals, user guides and informative blog postings so you can begin generating barcodes as efficiently as possible according to your desired specifications.

Our ASP.NET and PHP software can dramatically increase both personal and commercial productivity. Barcodes can be implemented in a variety of ways: from streamlining shipping to box-office ticketing, all while reducing resource loss. Automating the creation of barcodes means that manual data input can be reduced or eliminated, saving your industry time and money.

ASP.NET can be run on Windows. If your company is using the .NET technology, you can now take advantage of Barcode Generator.

Does barcode size matter?

Barcodes serve many purposes: from a QRCode advertisement on the side of a bus to an Intelligent Mail tracking barcode on an envelope. The size of the barcode will impact their utility greatly. Too small a barcode for an advertisement will go unnoticed and prove ineffective. Too large of a tracking barcode will leave little room for other important information like who the letter came from and who it is being sent to.

Function aside, these barcodes may involve very different methods for being scanned. One may target a consumer passing by with a smartphone, and the other may be interpreted using a handheld scanner. The size of the barcode will affect the readability between these two methods. Image-based readers that are installed on most smartphones will generally have no trouble as long as the barcode can be framed easily in the camera’s frame, but not microscopic.

For handheld LED style readers, there are generally specifications that should be followed to ensure readability. You can find these within the scanner’s manual which usually indicate a depth of field by a minimum barcode element width. This minimum element width corresponds to an individual bar within the barcode. These elements should be larger the further away your scanner is from the barcode. The depth of field refers to how far the scanner is from the barcode being scanned. Scanners have a limit this distance and if it is exceeded, they will not detect the barcode because it is not in its range. By adhering to the respective standards of your reader, you will be able to scan your barcodes with ease.

Another important consideration to bear in mind is that print quality can affect readability. You will need to verify that your printer is capable of printing at a small scale, should your project require it. This should be mentioned in the DPI (dots per inch) specifications that your printer manual provides. Inability to print smaller barcodes will appear as merged elements or unclear element boundaries. Definition in barcode elements is necessary for your reader to distinguish and interpret the data correctly.

The purpose of the barcode, distance of the scanner, and the print quality are factors that should be in mind when starting a project. There are many other considerations unrelated to size that must also be considered, such as the medium the barcode is printed on and its reflectivity. The process of finding the right barcode style to suit your needs is very much a trial-and-error process, but will prove to be much more profitable when the product is most suitable for its respective audience.

Barcode-related Scams

Some organizations, such as GS1, legitimately monitor barcode contents so that they are monitored, organized, and standardized for companies throughout the world. In order for a company or individual to comply with regulations, UPC and EAN codes are mandatorily purchased from GS1– a not-for-profit global standards organization. Many illegitimate organizations profit from consumers by offering these kinds of services. Some of these services include the monitoring of encoded barcode contents and the sale of rights to such contents.

Organizations that claim to monitor the usage of barcode contents so as to limit conflict between two users who might encode the same data generally have no merit or means to facilitate this type of service. When content monitoring is not standardized, provided by a singular central organization, and is not global, it has no value. The sale of rights to encoded content is often no more than the peddling of snake oil. Companies take advantage of consumers who are looking to label unique products. These consumers place their trust in the conduct of these organizations which make a profit appear from out of thin air.

It is important to research the company or organization that you are buying rights from. Verifying their credentials and making sure that they are a reputable and standardized source will ensure that your business remains profitable and resists falling victim to a scam.

Updated Graphical Interface

Barcode Generator implemented a new interface which has been available to customers of it’s 1D barcode software. More recently, this graphical interface has been released for 2D barcode systems as well. This new feature will be available to customers who purchase the latest version of a 2D Barcode Generator.

Here is an example of the QRCode graphical interface:

QRCode Example


What encoding do I use in a barcode?

When choosing how to implement barcodes that interact with sensitive information, you will want to consider your options and what is to be included within your barcodes.

The first method is to simply provide information directly within the barcode (such as client name, account number, etc.). If you are planning to have these barcodes scanned in an area that is offline from your database, this will most likely be the best method for you to use. However, there are some risks associated because anyone can scan the barcode and view the information within it. This may allow them to reproduce a counterfeit version or use the information in a fraudulent way.

The second method is recommended for most users. It involves using an ID within the barcode that, when scanned, will link to a database and retrieve the appropriate information associated with that ID. This ID can be any length or style of your choosing. When using numbers as an ID, however, you will want to consider using a “zerofill” method. This means using “0” as a placeholder to keep your ID length the same as you accumulate higher numbers within your barcodes. If you are concerned with keeping your barcodes the same size, this will generally alleviate the issue.

For most situations, we recommend using a 2D barcode system, such as QR Code, because it allows you to use a wide range of characters. This makes it particularly useful for the first method of implementation I discussed. It will also work the best for the second method as well because it also contains error correction. This is extremely useful when you are providing barcodes to be printed by your clients because you cannot always be sure of the quality of their printer and ink levels. It is also useful if the paper becomes warped or wrinkled (which can often be the case with things like print-at-home movie tickets and labels on shipped or stored items).


Adjusting the Height of a PDF417 Barcode

The latest edition of Barcode Generator includes functionality that will allow you to create PDF417 barcodes of different module heights. The documentation states that the row height should be 3 times bigger than the X-dimension (module width). However, some barcode readers can support reading smaller row heights. The larger of the two is the default and the suggested height, but it is possible to condense it if you so desire.

In order to do this, you will need to use the method setScaleY(1) within the BCGpdf417 class.

Recommended Size for PDF417 Barcodes
Recommended Size for PDF417 Barcodes

Condensed Size for PDF417 Barcodes
Condensed Size for PDF417 Barcodes

Scale vs DPI


Scale is the unit used when displaying an image on a computer screen, mobile phone, etc.

When setting the scale to 1, it represents the smallest unit that can be displayed on the screen. In 1D barcodes, this means each vertical black bar will be represented by a one pixel wide line. If you set a scale of 2, the vertical bar will be represented by a two pixel wide line, and so on.

This is the same concept for 2D barcodes: a black bit will be 1×1 pixels for scale of 1, and 2×2 pixels for scale of 2.

As you can see, it is not possible to choose a scale between 1 and 2 since a barcode cannot be written using 1.5 pixel sizes.

The size of the barcode itself will depend on the resolution and screen size of your user. For a same monitor size, if you compare a screen resolution of 1600×1200 and 800×600, the barcode will appear smaller to the eye on the first screen than the second.

This property can be set with the method “setScale(2)” from any barcodes.

As shown below, a larger scale will increase the size of the image displayed.

Scale 2 - DPI 72
Scale 2 – DPI 72

Scale 3 - DPI 72
Scale 3 – DPI 72

DPI (dot per inch)

This unit of scaling is for printing. This will tell your image how many “dots” (pixels) will be printed within one inch on paper. The default value is 72. The value usually used for printing is 300.

If you take two images with the same scaling (the images look exactly the same on the screen) but with a DPI of 72 and a DPI of 300, the first image will appear larger than the second one on paper. However, if your printer supports 300 DPI correctly, the second image will have a better quality than the first one.

This property can be set on the BCGDrawing object with “setDPI(300)”.

Two images of the same scale and different DPI’s will be displayed the same way on a screen:

Scale 3 - DPI 72
Scale 3 – DPI 72

Scale 3 - DPI 300
Scale 3 – DPI 300


If you plan to print your barcode, you must consider the setDPI() method. If you only display the image on the screen, then you would never need to use setDPI() and only the setScale() method.

If you want to have a bigger image than scale 1 but smaller than scale 2, you would need to resize the image with resampling. Doing so will introduce anti-aliasing in your image and possibly problems to read the barcode. Introducing anti-aliasing into an image means one bar for a 1D barcode will not be as clear as 1 pixel; it may be 1 pixel black, and 1 pixel gray.

If you still want to resize your barcode, you can use the method imagecopyresampled() from PHP by getting the image resource from the BCGDrawing with the method get_im().

Choosing the Right Barcode

1dor2dIn this first blog post, you will learn how to choose the right barcode. There are multiple available and some may suit more your needs than others. Gather your requirements and start reading.

Selling an item?

This is an easy first question to consider: are you selling this item? If no, skip this part. Yes? then you may want to consider the barcodes that are used in commercial fields such as:

  • UPC-A, UPC-E
  • EAN-13
  • Databar Expanded (coupon)

Data to Encode

One of the first requirements you should gather is the type of data you will encode in the barcode. Do you want to encode numbers, letters, or special characters? Not all barcode standards support the full ASCII. Make sure to read the manual of each of format to see which barcode will be able to support your data.


A particular size of barcode may be necessary for your needs. Different types of barcodes vary in size and shape. Some standards also allow for more size constraints to be added. Each standard allows a sample demonstration which should be used to test the size and shape of images you are trying to create.

Error Correction

Error correction within barcodes is very useful when you aren’t sure of the printer quality of the person printing the barcode or if you feel that your barcode may be slightly damaged (due to rips or tears in paper, fading from sunlight, etc.). Error correction can compensate for minor flaws in barcode printing or when a part of the barcode is covered when scanned.

1D or 2D

1D barcodes are much simpler than 2D barcodes. 2D barcodes generally allow for error correction and a much wider range of character use. 1D barcodes are great for coupon codes or small amounts of information and 2D barcodes are great for links, large amounts of data, and mobile tagging.


Following this guide should help you to select the most efficient barcode for your needs.