[dba-VS] Printing 'Code 128 A' Barcode Labels

Salakhetdinov Shamil mcp2004 at mail.ru
Fri Oct 27 19:38:18 CDT 2017

Hi Stuart --

Yes, only ASCII uppercase letters and numbers from 'Code 128 A' subset will be used in my barcode labels. I have just tried TTF and sample code you've provided to see if I will get proper barcodes' graphics for the sample source letters/numbers. Here is one example: 


When I used VBA code with XL it generated text string


for the source text string


and the resulting graphics weren't quite correct. Also TTF font max  size is 72 and width can't be adjusted AFAIS - this can be a "stopper" issue for using the custom code and TTF font.

Here is another C# solution, which seems to be working well for my first tests:  https://www.codeproject.com/Articles/14409/GenCode-A-Code-Barcode-Generator  . For my sample string it generates the folowing Hex codes:

68, 38, 10, 10, 11, 29, 25, 2D, 17, 2C, 13, 45, 6A

and draws a proper barcode graphics equal to  https://barcode.tec-it.com/en/Code128?data=X001IEM7L3  

Still to test more sample cases and find a way how to draw/print several bar codes on one A4-size page - this code


will probably have to be also used.

Also, I have just tried to use Code 128 TTF font with VS2017 WinForm's TextBox and it refused to use it reporting that "Only TTF fonts are supported". Strange. MS Excel does accept this Code 128 TTF font.

Thank you.

-- Shamil

>Friday, October 27, 2017 4:13 AM +03:00 from "Stuart McLachlan" <stuart at lexacorp.com.pg>:
>On 26 Oct 2017 at 8:46, Salakhetdinov Shamil via dba wrote:
>> Hi All --
>> I have to print 'Code 128A' barcode labels in one of my customers C#
>> applications' reports. Do you know any third-party tools lighter than
>> LEADTools (  https://www.leadtools.com/sdk/barcode-pro ) to solve my
>> task?
>> FYI: I have googled and I have found several solutions but all of them
>> look a bit ovewrpriced for a single task of just printing barcode
>> labels.
>> There seems to be also a free solution
>> ( https://www.codeproject.com/Articles/14409/GenCode-A-Code-Barcode-Gen
>> erator) but I'm not sure it will be useful for my case where I'll have
>> to print several labels in two columns in one A4 page.
>Does hit have to be Subset A?  (i.e. with ASCII Control characters).  If you are only after 
>letters and numbers, then the simplest solution is to download a Code128 font and write a 
>function to covert your data to an appropriate string.
>If you need to use A, it gets a bit more tricky.
>Here's a Code 128 TTF:  https://d13ot9o61jdzpp.cloudfront.net/files/code128.ttf
>And here's a VBA function to convert a string to a Code128 (B or C) string.  (I'm sure you can 
>covert it to C# fairly easily) 
>Public Function Code128(SourceString As String)
<<< skipped >>>

More information about the dba-VS mailing list