iOS, iPhone, and iPad Barcode Integration
Source Code Example
IDAutomation’s TrueType Barcode Fonts may be used in custom applications on the iPhone and iPad. The Xcode sample project and tutorial below show how this is achieved:
Drag the barcode font file into the resources folder
in the Project Window. For this example,
IDAutomationHC39M.ttf will be used.
Edit the Info.plist file and add IDAutomationHC39M.ttf to the "Fonts provided
by application" key:
Use the font name in your application to call the barcode font. For example, this
line of code applies the barcode font to a text field named Barcode:
[Barcode setFont:[UIFont fontWithName:@"IDAutomationHC39M" size:14.0]];
For all self-checking barcode fonts such as Code-39 that was
used in the example above, be sure to include the start
and stop digits. For example, to encode the text ABCDE,
the text to display or print using the Code-39 barcode
font would be *ABCDE* because the “*” character is
the start/stop digit for Code-39.
This sample code adds parentheses around the data from the DataToEncode text
field. This will have the same functionality as the asterisk but will hide the
start and stop characters in the human-readable data:
[Barcode etText: [NSString stringWithFormat:@"(%@)",[DataToEncode text]]];
Additional symbologies such as Code-128 require a check digit calculation, in addition to start/stop characters. IDAutomation provides several font encoders that include the code to perform this conversion that can be easily rewritten in Objective C for this purpose. Barcode Font license discounts may be considered in exchange for working converted code.