Home
PCL Barcode Font Kits - MEC Software Home Page
Contents
1. K VAL 4 6 A CHR ASC 0 VAL 6 3 Insert the center guard bar pattern 4 Add the remaining digits using Number Set C Input Num Compute Digit Set Character value 7 CHR ASC A VAL 7 8 Cc CHR ASC A VAL 8 9 C CHR ASC A VAL 9 0 C CHR ASC A VAL 0 1 Cc CHR ASC A VAL 1 5 Calculate the checksum a Starting from the right add up the digits in the even numbered positions 7 9 4 5 6 8 0 35 b Multiply the sum by 3 35 3 105 Starting from the right add the digits in odd numbered positions to the sum 105 1 9 7 4 9 1 136 d Perform a Modulo 10 division 136 Mod 10 6 e Subtract the result from 10 10 6 4 f If the result is 10 change it to zero In this case final result is 4 6 Add the checksum to the output string using Number Set C CHR ASC A VAL 4 tk 7 Add the right guard bar pattern 20 PCL Barcode Font Kits User Manual The sample file ModuleEAN13 bas contains the following Visual Basic functions that will perform the formatting functions Function format_ean instring As String As String Dim check As Integer Dim i As Integer Dim outstring As String Dim mychar As String Dim myset As String Dim setstr As String Dim mystring As String Make sure that we have been given 12 digits 1 If IsNull instring True Then mystring 00000
2. if Check 10 Check 0 sprintf PrintString L s 1dR ZipString Check 25 PCL Barcode Font Kits User Manual Planet Code The Planet Code is a variation of the Postnet code used by the United States Postal Service The height of the bars is inverted so each Planet character has three tall bars and two short ones The left and right frame bars are the same as Postnet and the checksum calculation method is the same Planet Code is used for four applications each with 12 digits Mailpiece rate pre sort bureau origin and customer identification e Computer on line notification and identification of person returning reply mail Sorting of foreign mail Automated address correction requests Planet Code fonts begin with PLA and use the same formatting rules as the Postnert fonts 26 PCL Barcode Font Kits User Manual License Agreement The fonts and other contents of the PCL Barcode Font Kits are protected by international copyright law and use of these materials is subject to restrictions Purchase of a license conveys limited permissions for use of the fonts and does not constitute transfer of ownership of the fonts which remains with the holder of the copyright If you purchased a Single Printer License the fonts may be used on only one printer The fonts may be transferred to a printer which replaces the printer for which the font license was originally purchased If you purchased a Multi
3. outstring End Function Function ean _check instring As String As Integer Dim cp As Integer Dim sum As Integer Dim ck As Integer 1 f Initialize the sum to zero and add up the values of characters in even positions starting from the right sum 0 For cp 12 To 1 Step 2 sum sum Val Mid instring cp 1 Next cp l Multiply the result by 3 then add in the values of characters in the odd positions 1 sum sum 3 For cp 11 To 1 Step 2 sum sum Val Mid instring cp 1 Next cp 1 Do a Modulo 10 division on the result and subtract it from 10 If the result is 10 set it to zero This is j the final checksum 1 ck 10 sum Mod 10 If ck 10 Then ck 0 End If ean_check ck End Function 22 PCL Barcode Font Kits User Manual Function ean_charset leftchar As String As String Dim Sets As Variant Dim MyVal As Integer t This array defines the parity pattern to be used for digits j 2 through 7 The pattern encodes the value of the first l character 1 Sets Array AAAAAA BBABAA BABBAA ABBBAA BBAABA BAABBA AABBBA BABABA ABBABA ABABBA Get the numeric value of the first left most character and i return the correct string based on its value 1 MyVal Val leftchar If MyVal lt 0 Or MyVal gt 9 Then MyVal 0 End If ean _ charset Sets MyVal End Function Function ean _ char datachar As String charset As String As String Dim i
4. 41 Left Right 0 A 1 B 2 C 3 D 4 E 5 F 6 G 7 H 8 9 J Let s say we wish to encode the number 0 00123 45678 4 dashes are shown for clarity Each of the following examples would produce the same result 000123 EFGHIE 000123 EFGHIE 000123 EFGHIE The programmer must also calculate the value of the check digit The sample code shown on the following page calculates the check digit and formats the complete string 16 PCL Barcode Font Kits User Manual Format UPC A with C static char upc_string 20 char format_upc char instring char cpin cpout int check int i memset upc_string 0 sizeof upc string check upc check instring calc check digit cpin instring point at instring cpout upc string point at outstring cpoutt insert left guard for i 1 i lt 6 i insert first 6 digits cpout cpin 0 cpout insert center guard for i 1 i lt 5 i insert next 5 digits cpout A cpin 0 remember A J cpout insert right guard return upc string return to caller int upc _check char instring int mysum mycheck char cp mysum 0 start with a zero cp instring point at start of string while cp 0 go until end of string reached mysum cp 0 add numeric value of character cp 2 go to next odd numbere
5. the string functions will interpret them as formatting characters and give you incorrect results Either avoid the standard string functions or test for and characters 12 PCL Barcode Font Kits User Manual Code 128 Character Table This table lists all of the characters available within Code 128 The value column is the numeric value of the character which should be used in calculation of the checksum The font location column is the character code which should be sent to the PCL printer to print that character The Subset A B and C columns give the meaning of the character in each subset Font Sub Sub Sub Font Sub Sub Sub Value Loc A B C Value Loc A B C 32 SP SP 00 54 86 V V 54 1 33 01 55 87 W W 55 2 34 k g 02 56 88 X X 56 3 35 03 57 89 Y Y 57 4 36 04 58 90 Z Z 58 5 37 05 59 91 59 6 38 amp amp 06 60 92 60 7 39 07 61 93 61 8 40 08 62 94 A 62 9 41 09 63 95 _ _ 63 10 42 i 10 64 96 NUL 64 11 43 11 65 97 SOH a 65 12 44 12 66 98 STX b 66 13 45 13 67 99 ETX c 67 14 46 14 68 100 EOT d 68 15 47 15 69 101 ENQ e 69 16 48 0 0 16 70 102 ACK f 70 17 49 1 1 17 71 103 BEL g 71 18 50 2 2 18 72 104 BS h 72 19 51 3 3 19 73 105 HT i 73 20 52 4 4 20 74 106 LF j 74 21 53 5 5 21 75 107 VT k 75 22 54 6 6 22 76 108 FF 76 23 55 7 7 23 77 109 CR m 77 24 56 8 8 24 78 110 SO n 78 25 57 9 9 25 79 111 SI o 79 26 58 i 26 80 112 DLE p 80 27 59 27 81 113 DC1 q 81 28 60 lt lt 2
6. 0000000 ElseIf Len instring lt 12 Then mystring For i 1 To 12 Len instring mystring mystring amp 0 Next i mystring mystring amp instring ElseIf Len instring gt 12 Then mystring Mid instring 1 12 Else mystring instring End If mystring now contains the input data string Determine what pattern of EAN character sets should be t used based on the leftmost character The choice of j character set pattern encodes the value of the first digit setstr ean_charset Mid mystring 1 1 y Start with the left guard bar pattern outstring Insert the next 6 digits looking up the correct character based on the EAN character set for each position We do not insert the first character it is encoded in the parity pattern of digits 2 through 7 For i 2 To 7 mychar Mid mystring i 1 myset Mid setstr i 1 1 outstring outstring amp ean_char mychar myset Next i l Insert the center guard 1 outstring outstring amp 21 PCL Barcode Font Kits User Manual Now insert the next 6 digits 1 For i 8 To 12 mychar Mid mystring i 1 outstring outstring amp ean_char mychar C Next i Calculate the check digit and append it to the string 1 check ean_check mystring outstring outstring amp ean_char Chr check C 1 i Add the right guard bar pattern and return to caller 1 outstring outstring amp format_ean
7. 5 9 or 11 digits of Zip Code data and must be calculated for each barcode When the barcode is read the scanning equipment performs the same calculation and compares its result with the check digit that was read from the barcode If the two do not match the scanner knows that there is something wrong with the data and can eject the letter for manual sorting Here is the general method for calculating the checksum Starting from the left sum all of the digits in the barcode Using the example above 1 2 4 3 4 4 5464 74 84 9 45 For the next step we need the units column of the sum You can extract this information using Modulo 10 division which is the same as dividing by 10 and taking the remainder Basic 45 MOD 10 5 C 45 10 5 Subtract this result from 10 to obtain the check digit if the final result is 10 change it to zero In the example above the check digit would be 5 Here is a bit of sample code written in Basic ZipString 123456789 Sum 0 FOR x 1 to LEN ZipString Sum Sum VAL MIDS ZipString x 1 NEXT x Check 10 Sum MOD 10 IF Check 10 THEN Check 0 ENDIF PrintString L ZipString Strs Check R 24 PCL Barcode Font Kits User Manual Here is the same function in C char ZipString 20 PrintString 20 cp int Sum Check strepy ZipString 123456789 Sum 0 cp ZipString while cp 0 Sum cp 0 Check 10 Sum 10
8. 8 82 114 DC2 r 82 29 61 7 29 83 115 DC3 s 83 30 62 gt gt 30 84 116 DC4 t 84 31 63 2 31 85 117 NAK u 85 32 64 32 86 118 SYN v 86 33 65 A A 33 87 119 ETB Ww 87 34 66 B B 34 88 120 CAN x 88 35 67 C C 35 89 121 EM y 89 36 68 D D 36 90 122 SUB Z 90 37 69 E E 37 91 123 ESC 91 38 70 F F 38 92 124 FS 92 39 71 G G 39 93 125 GS 93 40 72 H H 40 94 126 RS 3A 94 41 73 l l 41 95 127 US DEL 95 42 74 J J 42 96 128 FNC3 FNC3 96 43 75 K K 43 97 129 FNC2 FNC2 97 44 76 L L 44 98 130 SHIFT SHIFT 98 45 77 M M 45 99 131 SUB C SUB C 99 46 78 N N 46 100 132 SUB B FNC4 SUB B 47 79 O O 47 101 133 FNC4 SUB A SUB A 48 80 P P 46 102 134 FNC1 FNC1 FNCI1 49 81 Q Q 49 50 82 R R 50 103 135 Start Code A 51 83 S S 51 104 136 Start Code B 52 84 T T 52 105 137 Start Code C 53 85 U U 53 138 Stop 13 PCL Barcode Font Kits User Manual Interleaved 2 of 5 Interleaved 2 of 5 is a compact numeric only barcode that encodes a pair of digits on each barcode character For example 35 is encoded as a single character when this character is read by the barcode scanner it is separated into two digits before transmission to the computer The character which represents the digit pair 00 is located where you would expect to find the zero character ASCII character value 48 By adding the numeric value of the desired digit pair to the ASCII value of the zero character you will obtain the ASCII value of the character that you should print In Visual Basic for
9. 9 character set includes the upper case alphabet A Z digits 0 9 and the following symbols hyphen period space dollar sign slash plus sign and percent sign PCL Barcode Font Kits User Manual Extended Code 39 At times it may be necessary to encode a character which is not part of the normal Code 39 charac ter set Extended Code 39 or Full ASCII Code 39 is a method that allows encoding of all 128 ASCII characters These barcodes must be read using a scanner which has been configured for Extended Code 39 The official AIM specification for Code 39 lists Extended Code 39 as an Op tional Characteristic and uses the following language Readers can be programmed to respond to Code 39 symbols in non standard ways to satisfy particular application requirements Since use of these features requires special reader program ming they are not recommended for general applications where there would exist the possibility of ambiguity of interpretation with standard Code 39 symbols The upper case alphabet the digits O through 9 the space the dash and the period are encoded just like standard Code 39 All others are encoded with a pair of barcode characters The percent sign dollar slash and plus sign are followed by a second character for example the pair M will be scanned as a carriage return code The scanner must be configured to read Extended Code 39 ASCII C39
10. ASCII C39 ASCII C39 ASCII C39 NUL U SP _ YN W SOH A A A A a A STX B i B B B b B ETX C IC C C c C EOT D D D D d D ENQ E E E E e E ACK F amp F F F f F BEL G i IG G G g G BS H H H H h H HT I l i l LF J i IJ J J j J VT K K K K k K FF L i L L L l L CR M a M M m M SO N N N n N SI O O O O 0 O DLE P 0 0 P P p P DC1 Q 1 1 Q Q q Q DC2 R 2 2 R R d R DC3 T 4 4 S S S S DC4 T 4 4 T T t T NAK U 5 5 U U u U SN V 6 6 V V v V ETB w 7 7 W W w W CAN X 8 8 W W w W EM Y 9 9 Y Y y Y SUB z IZ Z Z Z Z ESC SoA F K P FS B lt G AL Q GS C H M R RS D gt Sl N S US E J O DEL T X Y Z PCL Barcode Font Kits User Manual Modulo 43 Checksum for Code 39 A checksum is an extra character which is added to the end of a barcode just before the stop character the value of the checksum is computed from the preceding characters in the barcode so it will change depending on the data contained in the barcode The software that creates the barcode is responsible for performing the calculation and adding the checksum character The scanner reads the barcode performs the same checksum calculation and compares the result of this calculation to the checksum at the end of the barcode If the two do not match the scanner presumes that something is wrong and does not accept the scan In practice the Modulo 43 checksum is seldom u
11. As Integer l This function returns the character that should be printed based on the value of the character and the particular character set that should be used A B or C i Val datachar If charset A Then i Val datachar Asc 0 ElseIf charset B Then i Val datachar Asc K ElseIf charset C Then i Val datachar Asc A End If ean_char Chr i End Function 23 PCL Barcode Font Kits User Manual Postnet The Postet barcode is the row of tall and short bars that often appear below or above an address on a letter Postnet encodes the Zip Code so that it can be read by automatic sorting equipment A Postnet barcode can include the 9 digit Zip 4 code or the 11 digit Delivery Point Code which is the same as Zip 4 with two extra digits to define the destination in more detail Each digit is repre sented by five bars two tall and three short and the complete barcode is constructed as follows Start character one tall frame bar or guard bar represented by letter L or left Numeric data 5 digits for Zip Code 9 digits for Zip 4 or 11 digits with Delivery Point Code Check Digit Stop character one tall frame bar or guard bar represented by letter R or r right For example the following text string will produce a complete Postnet barcode L1234567895R The check digit is used to insure accuracy when the barcode is scanned The check digit is calcu lated using the
12. INC Software PCL Barcode Font Kits Downloadable barcode fonts for PCL compatible printers User Manual PCL Barcode Font Kits User Manual PCL Barcode Font Kits Downloadable barcode fonts for PCL compatible printers User Manual c Copyright 2001 2003 Measurement Equipment Corporation All rights reserved Distributed By The Barcode Software Center 1113 Hull Terrace Evanston IL 60202 USA Tel 847 866 9836 www makebarcode com PCL Barcode Font Kits User Manual Introduction While most laser printers do not include any internal barcode fonts printers which are compatible with Hewlett Packard s PCL 5 printer command language are capable of accepting downloaded fonts One or more barcode fonts can be stored in the printer s memory and then used by embed ding appropriate control sequences in the printer data stream Downloaded barcode fonts offer some advantages The cost per printer is much lower than hardware solutions Performance is faster than downloading barcode graphic images Barcodes can be printed from virtually any operating system All of the fonts are created to produce precision barcodes on printers with 300 dpi or greater resolu tion PCL fonts offer much greater precision than TrueType and other types of scaleable fonts bar widths and spacings are accurate producing consistently better scanning results Each Barcode Font Kit supports a single type of barcode and includes a selectio
13. Printer License you may use the fonts on several printers simulta neously up to the number specified in the license which you purchased provided that all of the printers are owned or controlled by the same organization For example if your company owns 8 printers located at different offices a 10 Printer License will cover all of the printers You may not permit an outside individual company or organization to use the remaining 2 printers allowed under the license If you purchased a Developer License you may distribute up to 10 000 copies of the fonts pro vided that the fonts are distributed as a part of a software package which you sell and that only the specific font files actually used by your software package are distributed Under no circumstances may the fonts be distributed as a product separate from a software package developed and or sold by you Distribution of fonts within a single organization as part of a software package is permitted under this license agreement By using the PCL Font Kit s you agree to the terms of this license agreement and further agree to protect the fonts and other materials from unathorized copying use or distribution 27
14. UPC A UPC A is used in the United States and Canada to identify retail products for checkout scanning The code is fixed length 12 digits numeric only The Uniform Code Council located in Dayton Ohio assigns identification numbers to manufacturers the barcode begins with a leading number system digit also assigned by the UCC followed by the manufacturer s identification This is followed by digits which identify each of the manufacturer s products The final 12th digit is a check digit used to insure scanning accuracy The barcode also includes left center and right guard characters Character Position Function 1 left guard 2 number system digit 3 7 5 digits manufacturer ID 8 center guard 9 13 5 digits product number 14 check digit 15 right guard The left guard and right guard characters are identical and can be printed using an asterisk or left and right parentheses or square brackets The center guard character may be printed using a hyphen or a vertical pipeline symbol The bar pattern for digits in the left half of the barcode is different from the pattern used on the right side In the PCL Font Kit left side digits are represented in the normal way by the characters 0 through 9 Right side digits are represented by the letters A through J For a programmer encod ing the right side digits is simply a matter of adding the numeric value of each digit to the ASCII value for the character A
15. aracters from the input string 8 through 12 using Character Set C which starts in the font at A CHR ASC A VAL mychar Print mychar using set C 19 PCL Barcode Font Kits User Manual The next step is to calculate the checksum Starting from the right end of the input data string add the numeric values of the digits in the even numbered positions the right most character is in position 1 so start with the second character from the right Multiply the sum by 3 Then start back at the right end with the character in position 1 and add the numeric values of the digits in the odd numbered positions into our sum Finally perform a Modulo 10 division on the sum divide by 10 and use the remainder Subtract the result from 10 if the answer is 10 change it to zero This is the checksum Add this character to the finished barcode string using Number Set C Finish the string with a guard bar pattern asterisk For example let s print an EAN 13 barcode using the string 719954678901 qs Start the output string with a guard bar pattern 2 The first digit in our string is a 7 Using our chart on the preceding page we will use a pattern of number sets BABABA Add the next 6 digits to the output string Input Num Compute Digit Set Character value 1 B CHR ASC K VAL 1 9 A CHR ASC 0 VAL 9 9 B CHR ASC K VAL 9 5 A CHR ASC 0 VAL 5 4 B CHR ASC
16. arity because the total number of dark modules 3 is odd This particular pattern encodes a zero which can also be printed with even parity as 01000111 To format a string for printing as an EAN 13 symbol begin with a start code represented by an asterisk The next step is to use the first character in the input string to decide what parity pattern to use Number set A uses odd parity and number set B uses even parity 1st Number Digit Set to use AAAAAA BBABAA BABBAA ABBBAA BBAABA BAABBA AABBBA BABABA ABBABA ABABBA OONODARWNM OO For example if the first digit in the data string is 4 then we should use the pattern BBAABA The second digit in the data string the first digit to be printed in the barcode and the one after it should be printed using Number Set B the 4th and 5th digits in the data string should use Number Set A the 6th digit should use Number Set B and the 7th digit should use Number Set A The ten characters for Number Set A begin at 0 in the font and Number Set B begins at K To print a character using Set A add the numeric value of the digit to the ASCII value for 0 CHR ASC 0 VAL mychar Print mychar using set A CHR ASC K VAL mychar Print mychar using set B After digits 2 through 7 from the input string have been added to the finished string add the center guard bars using a vertical pipe symbol or a hyphen Print the remaining ch
17. char datastring returns the checksum character for datastring This character should then be appended to datastring followed by the stop character c hp128 checksum mystring The function hp128_stop void returns the Code 128 stop character c hp128_stop There are two other functions included in HP_128 that are useful The first pcl_select_font returns a pointer to a PCL command string that will select the desired font For example if the barcode font has an ID number of 25801 and the file pointer for the printer is Ip fprintf lp s hp select font 25801 The second function pcl_transparent instructs the printer to print the next n characters without checking them for command codes This will prevent barcode data including the checksum from being incorrectly interpreted as a command Use it immediately before sending the barcode string to the printer For example if mystring contains the complete barcode start character data checksum and stop character and the file pointer for the printer is Ip fprintf lp s pcl transparent strlen mystring One other PCL instruction which is not included in HP_128 selects the default font on the printer This is the font which has been selected on the printer s control panel After printing a barcode you will have to change back to a normal text font and using the default may be preferable to specifying a particular font This instruction will switc
18. d position mysum mysum 3 multiply sum so far by 3 cp instring start again at beginning Cp move to first even position while cp o go until end of string mysum cp 0 add numeric value of character cp 2 go to next even position mycheck 10 mysum 10 calculate Modulo 10 if mycheck 10 force result of 10 to 0 mycheck 0 return mycheck done return the result 17 PCL Barcode Font Kits User Manual Format UPC A with Basic Function format _upc instring As String As String Dim check As Integer Dim i As Integer Dim MyString as String Dim MyChar as Integer MyString left guard MyString MyString amp LeftS instring 6 first 6 digits MyString MyString amp center guard for i 7 to 11 next 5 digits MyChar Val Mid instring i 1 get digit MyChar MyChar Asc A offset to ABC MyString MyString amp Chr MyChar add to string next i MyChar upc _check instring Asc A check digit MyString MyString amp Chr MyChar add to string MyString MyString amp right guard format _upc End Function MyString Function upc check instring As String Dim MySum As Integer return to caller As Integer Dim i As Integer mysum 0 start with a zero for i 1 to 11 Step 2 add digits in odd positions mysum mysum Val Mid instring i 1 next i my
19. example Chr 48 57 would print the barcode character for 57 The start and stop characters are represented by the left and right parentheses and An Interleaved 2 of 5 barcode may include a checksum which is calculated using the Modulo 10 method Since the final barcode string including the checksum must have an even number of digits an extra character typically a leading zero may have to be added to the original data The checksum is calculated on the string of digits before they are divided into pairs the start character is not included in the calculation 1 Starting with the digit in position 1 the left most digit add the values of all the digits in the odd numbered character positions 1 3 5 etc 2 Multiply the result of Step 1 by 3 3 Add the values of the digits in the even numbered positions to the result of Step 2 4 Perform a Modulo 10 division on the result of Step 3 that is divide the result of Step 3 by 10 and take the remainder 5 Subtract the result of Step 4 from 10 if this result is 10 change it to zero This is the checksum which should be appended to the end of the data string The following sample Visual Basic function will return a formatted string for printing as an Inter leaved 2 of 5 barcode Function FmtITF InString As String Checksum As Boolean As String Dim i As Integer Dim MySum As Integer Dim WorkString As String Dim FinishedString As String Dim PairVal As Inte
20. f the pair 00 99 and send the result to the printer The value of the character for the checksum is the numeric value of the pair For example 55 would be sent to the printer as 87 55 32 and its value for the checksum would be 55 Calculating the Code 128 Checksum Code 128 requires that a modulo 103 checksum be appended to the barcode The checksum includes the start character and all subsequent data and control characters but not the stop charac ter Calculate the checksum as follows 1 Initialize the checksum with the value of the start character used 103 104 or 105 for Subset A B or C 2 Initialize a multiplier to 1 3 Starting at the left end of the barcode add the value of each character times the multiplier to the checksum Increment the multiplier by one after each character 4 Divide the result by 103 The remainder is the checksum For example calculate the checksum for the word HELLO using Subset B Start Code B 104 H 40 1 40 E 37 2 74 L 44 3 132 L 44 4 176 O 47 5 235 The total is 761 and 761 modulo 103 is 40 761 103 7 with remainder of 40 and that is the value of the character that should be printed The ASCII character code to be sent to the printer is 72 40 32 Special caution for C programmers Be careful when using string functions sprintf fprintf etc when formatting barcodes Checksums can come out to any value and if they resolve to a backslash or percentage sign
21. ger Dim CharVal As Integer Dim PairString As String check for illegal alpha characters If IsNumeric InString False Then FmtITF Exit Function End If 14 PCL Barcode Font Kits User Manual insure even number of digits in final string i Len InString Mod 2 If Checksum False And i lt gt 0 Or Checksum True And i 0 Then WorkString 0 amp InString Else WorkString InString End If calculate checksum if requested If Checksum True Then MySum 0 y Add up all digits in the odd numbered positions then multiply result by 3 For i 1 To Len WorkString Step 2 MySum MySum Val Mid WorkString i 1 Next i MySum MySum 3 Add in all digits in even numbered positions For i 2 To Len WorkString Step 2 MySum MySum Val Mid WorkString i 1 Next i i Finish the calculation MySum MySum Mod 10 MySum 10 MySum If MySum 10 Then MySum 0 End If WorkString WorkString amp Format MySum End If Build the finished string by mapping pairs of digits ij to correct character positions in the font FinishedString For i 1 To Len WorkString Step 2 PairString Mid WorkString i 2 PairVal Val PairString CharVal PairVal Asc 0 FinishedString FinishedString amp Chr CharVal Next i FinishedString FinishedString amp stop character FmtITF FinishedString End Function 15 PCL Barcode Font Kits User Manual
22. h to the default font fprintf lp 033 3 For a complete example of how to use these functions see the source code for EXAMPLE C which is included on the release disk for the Code 128 PCL Font Kit Character Value vs Location in Font The characters in Code 128 are numbered from 0 through 102 plus the start and stop characters this number is shown in the Value column of the chart at the end of this section and is used to calculate the checksum The ASCII character codes recognized by PCL printers begin at 32 space these codes are shown in the Location in Font column Printable ASCII characters can be printed in Subset A or B simply by sending the character s ASCII code to the printer For purposes of calculating the checksum the value of the character is 32 less than its ASCII code For example the value of the letter A ASCII code 65 when calculating the checksum is 33 65 32 Subset A permits printing of control characters those with ASCII codes between 0 and 31 To print a control character add 96 to its ASCII code and send the result to the printer For example to send a form feed ASCII 12 add 96 and send the result 12 96 108 To obtain the value of this character for the checksum calculation add 64 to its ASCII code For example 12 64 76 11 PCL Barcode Font Kits User Manual Subset C prints pairs of digits as single barcode characters To print a pair of digits add 32 to the numeric value o
23. in the font kit would be C3925501 DSF this is the PCL command to select the font lt esc gt 25501X To switch back to the printer s default font send this command lt esc gt 3 So we can print a barcode in our sample report just by adding a few simple escape sequences lt escape sequence to select big and bold type gt My Final Report to the Committee lt escape sequence to select small type gt lt escape sequence to position cursor farther down the page gt blah blah blah lt esc gt 25501X 123456 lt esc gt 3 Here are snippets of program code to produce the last line of this sample G sprintf mystring 033 25501X 123456 033 3 Visual Basic mystring Chr 27 amp 25501X 123456 amp Chr 27 amp 3 5 PCL Barcode Font Kits User Manual Adding Readable Text to a Barcode The fonts do not include readable text characters Adding the text with a separate print command is easy to do and gives the programmer complete freedom in choosing the style and position of the text The simplest way to print text below a barcode is to print the barcode start a new line and then print the data again using a plain text font Here is an example in C that uses the fprintf function to send formatted data to the printer lp In practice programmer would probably write this as one or two lines of code we have used several lines for clarity fprintf lp 033 25501X select the barcode font fprin
24. meric only data for significant space savings Those features come with a cost more complexity for the programmer but it isn t too bad if taken one step at a time Code 128 includes 103 character codes but there are three ways to interpret the codes Where most barcode symbologies define a single start code Code 128 has three start codes to choose from Subset A Subset B and Subset C The meaning of a scanned character depends on the subset currently being used Each subset includes codes to switch to either of the other two sub sets making it possible to mix subsets within a single barcode The ability to switch subsets pro vides a wide range of capabilities to satisfy almost any application Subset A contains the standard ASCII characters and control codes printable symbols upper case alphabetic characters the digits 0 through 9 and control codes NUL SOH STX ETX etc Subset B is similar to Subset A but the control codes are replaced by lower case alphabetic charac ters Subset C includes numbers only but encodes two digits into each barcode character increas ing the amount of data that can be printed in a limited space Note that the data to be encoded in Subset C must have an even number of digits Since each subset switch requires insertion of a control character it is a good idea to keep switch ing to a minimum For instance putting a numeric only Subset C field in the middle of a barcode would cost two control charac
25. n of fonts with barcode heights from 0 25 to 2 00 in increments of 0 25 with narrow bar widths from 6 7 mils to 20 mils and where appropriate with bar width ratios from the minimum to maximum allowed Each font is identified by a unique number so several barcode fonts can be downloaded to the printer the total number is limited only by available printer memory Each kit includes a file with a list of all the fonts included in the kit C39LIST TXT Code 39 C28LIST TXT Code 128 ITFLIST TXT Interleaved 2 of 5 UPCLIST TXT UPC A EANLIST TXT EAN 13 POSILIST TXT Postnet The barcode fonts do not include readable text below the bars the variety of available typefaces and sizes would create an overwhelming range of choices It is much easier to print the readable text using a separate PCL instruction Using the PCL barcode fonts is relatively easy I Modify the printer data stream to include the required command sequences 2 Download the desired barcode font s to the printer s 3 Send data to the printer PCL Barcode Font Kits User Manual Downloading Fonts to the Printer Look at the list file file which accompanies the kit C39LIST TXT for example and choose one or more fonts with suitable height width and ratio To send a font to the printer simply copy it to the printer port In MS DOS use the b binary command line option C gt copy b C3925501 DSF lpti If you are in a DOS command prompt under Windo
26. riting PCL uses Escape Sequences to control the printer An escape sequence always begins with the ASCII Escape code which has a decimal numeric value of 27 33 in octal The Escape code shown in the samples below as lt esc gt is followed by a series of parameters which tell the printer what to do An escape sequence may include more than one parameter Each parameter generally consists of a value followed by a letter which identifies the type of parameter If the parameter letter is lower case it means that another parameter follows it If the parameter letter is upper case it means that it is the last parameter and it marks the end of this particular escape sequence It is certainly possible to print plain text on a PCL printer without using escape sequences but the text will be plain and printed line by line teletype style We can produce more elaborate results by inserting escape sequences to control the type style position of the text on the page and so on lt escape sequence to select big and bold type gt My Final Report to the Committee lt escape sequence to select small type gt lt escape sequence to position cursor farther down the page gt blah blah blah 123456 Once a barcode font has been downloaded to the printer you can select it by embedding this PCL command in the data being sent to the printer lt esc gt nX where nis the font ID number For example if the font ID number is 25501 the name of the file
27. rver gt P lt printer gt C lt class gt U lt job name gt O lt option gt lt filename gt As an example let s assume that the destination printer is available at IP address 192 168 100 40 and a file named C3925501 DSF contains the downloadable PCL barcode font We must use O option followed by a lower case letter L to specify binary mode lpr S192 168 100 40 P192 168 100 40 Ol C3925501 DSF Downloading a font requires about 1 to 2 seconds Several fonts can be downloaded to a printer provided that each has a different ID number and the printer has sufficient memory The fonts in the PCL kit are tagged as permanent fonts which means that they will survive a variety of printer commands that clear the printer s memory However the fonts cannot survive every printer com mand and they certainly cannot survive loss of power to the printer Therefore it is always a good idea to download fonts at the start of each print job where they will be needed This can be done as part of a batch file or shell script Even if a font is already in the printer s memory reloading a font takes only 1 or 2 seconds and will simply replace the old font with the new one PCL Barcode Font Kits User Manual Selecting Fonts with Escape Sequences PCL compatible printers understand and respond to Hewlett Packard s Printer Command Language PCL The PCL Font Kits are compatible with PCL Version 5 and higher higher being PCL 6 as of this w
28. sed While it does provide an additional level of reliability Code 39 has other checks built into its structure that assure a level of accuracy more than adequate for most applications A Code 39 barcode is presumed not to include a checksum unless explicitly required To calculate a Modulo 43 checksum first assign each character in the barcode a numeric value according to the following table Character Value Character Value Character Value 0 0 F 15 U 30 1 1 G 16 V 31 2 2 H 17 W 32 3 3 18 X 33 4 4 J 19 Y 34 5 5 K 20 Z 35 6 6 L 21 36 7 7 M 22 37 8 8 N 23 Space 38 9 9 O 24 39 A 10 P 25 40 B 11 Q 26 41 C 12 R 27 42 D 13 S 28 E 14 T 29 Sum the numeric values of the characters in the barcode exclude the start stop characters and divide the result by 43 the remainder is the checksum value Convert this to a character using the table above and add that character to the end of the barcode just before the stop character In programming parlance dividing and taking the remainder as the result is a Modulo division In Basic it would be expressed as Checksum MySum Mod 43 In C C it would be Checksum MySum 43 PCL Barcode Font Kits User Manual Code 128 Code 128 has more features than Code 39 For example the character set includes all of the printable ASCII characters upper case lower case and all symbols it includes the non printable ASCII control codes and there is a method for compressing nu
29. sum mysum 3 multiply result by 3 for i 2 to 10 Step 2 add digits in even positions mysum mysum Val Mid instring i 1 next i MySum MySum Mod 10 calculate Modulo 10 MySum 10 MySum subtract from 10 if MySum 10 then force 10 result to 0 MySum 0 endif upc check MySum End Function 18 PCL Barcode Font Kits User Manual EAN 13 EAN 13 is the retail barcode used everywhere in the world outside North America While the first digit in a UPC A code defines the number system the first 2 or 3 digits in an EAN 13 code identify the country in which the code is registered The EAN 13 symbol is almost identical to the UPC A symbol but encodes 1 extra digit a total of 13 digits into the same number of bars and spaces The first left most digit in an EAN 13 data string is not explicity printed as a separate character in the barcode Instead EAN 13 takes advantage of the fact that any of the individual barcode characters can be printed using even or odd parity the first character is encoded in the even odd parity pattern in the six left hand digits of the barcode So what does parity mean Each EAN character is made up of 7 modules which are combined to form 2 bars and 2 spaces If we use 0 to represent a white module and 1 to represent a dark module 0001101 would indicate a space 3 modules wide a bar 2 modules wide a space 1 module wide and a bar 1 module wide This is odd p
30. t s say that the data to be encoded is PN334958 The finished string ready for printing as a Code 39 barcode would look like this PN334958 Here is a complete set of escape sequences to print the data as a barcode and then print the information again as text using the printer s default font below the barcode lt esc gt 25501X PN334958 lt esc gt 3 PN334958 The result will look something like this MVM PN334958 Here is a C function that will produce this output the caller passes the desired font number fontid the data partno and a pointer to the output file or device prn The code 033 in C represents Octal 33 which is the escape character int SendBarcode int fontid char partno FILE prn fprintf prn 033 dx fontid select the font fprintf prn s partno send part number fprintf prn 033 3 n default font fprintf prn s n partno text part number return 0 all done Here is Visual Basic code that will return a string with similar results Chr 27 is the escape code Function SendBarcode fontid as integer partno as string as String Dim MyString as String MyString Chr 27 amp amp fontid amp x MyString MyString amp amp partno amp MyString MyString amp Chr 27 amp 3 amp vbcrlf MyString MyString amp partno SendBarcode MyString End Function The Code 3
31. ters switch to Subset C and back again It would be more efficient to put the numeric data at the end or beginning of the barcode so only one subset switch is needed Building and printing a Code 128 barcode A Code 128 barcode begins with a start code for either Subset A B or C see the code chart at the end of this section for the specific character value This is followed by the data to be printed Following the data is a checksum which is calculated based on all of the characters in the code from the start character through the last data character The method for calculating the checksum is given below The stop character is inserted after the checksum lt start character gt lt data gt lt checksum gt lt stop character gt The Code 128 PCL Font Kit includes a C language module HP_128 which provides basic func tions to assist with building a barcode The linkable modules are HP_128_S OBJ small memory model and HP_128 _L OBJ large memory model the source code is in file HP_128 C Here is a summary of the functions available The function hp128_start_subset char subset returns the start character for the desired subset For example c hp128 start subset B The function hp128_switch_subset char from char to inserts the control code to change from one subset to another in the middle of a barcode c hp128 switch _subset B A 10 PCL Barcode Font Kits User Manual The function hp128 checksum
32. tf lp 123456 send the data with asterisks fprintf lp 033 3 switch to the default font fprintf n send a new line code fprintf lp 123456 send the data again as text By using PCL cursor positioning commands selecting specific typefaces and controlling type size and boldness the programmer can create virtually any finished appearance desired Details on the PCL commands are beyond the scope of this manual but are discussed at length in Hewlett Packard s publication PCL5 Printer Language Technical Reference Manual Formatting Barcode Strings The last piece of the puzzle is to format the data which will be inserted in the barcode This process can be simple or a bit complex depending on the type of barcode you have decided to use Code 39 vs Code 128 for example and your comfort level with programming Each PCL Barcode Font Kit contains a set of fonts for one type of barcode and sample files which demonstrate how to format the data and perform any necessary calculations Details about formatting each type of barcode can be found on the following pages PCL Barcode Font Kits User Manual Code 39 This is the easiest type of barcode to use Formatting of the data string requires only that you add an asterisk at the beginning and at the end of the data The asterisk is translated to the Code 39 start stop character which the scanner must see to recognize the code For example le
33. ws and the destination printer is on the network using the printer s network name may not work depending on your version of Windows For ex ample this command should send the font to the printer under Windows 98 and Windows 2000 but may simply make a copy of the file on disk with Windows 95 C gt COPY B CODE39 DSF MAIN LASER You may first have to assign the printer to a local printer port with the NETUSE command The port does not have to physically exist and you should not use a port that actually has a local printer attached to it For example if you have local printers attached to LPT1 and LPT2 and a network printer named Main Laser you could assign LPTS to the network printer C gt NETUSE LPT3 MAIN LASER C gt COPY B CODE39 DSF LPT3 In Unix or Linux you can use the cat command to copy the file to the raw device The raw device usually has the same name as the device you commonly use but with an r on the end Using the raw device avoids the possibility that a print driver or spooler will insert formatting codes into the font as it is sent to the printer cat usr myfiles C3925501 DSF dev lptir The lpr command can be an effective method for downloading fonts Unix and Linux support lpr Windows NT 2000 and XP also support lpr but it may not be installed by default lpr may be called Unix printing by the Windows setup process The general form of the lpr command is lpr S lt se
Download Pdf Manuals
Related Search
Related Contents
IO BOARD PNP DRIVER MANUAL dossier - Chambre Syndicale Française de l`Etanchéité (CSFE) 取扱説明書(V-1150) istruzioni xdva1621 TP-LINK TD-W8970B Mode d`emploi pour la table traçante digitale Samsung AM056FNCDEH/EU Felhasználói kézikönyv User Manual Sony WM-FS473 User's Manual Copyright © All rights reserved.
Failed to retrieve file