Printing Barcodes

From BR Wiki
Jump to navigation Jump to search

Printing barcodes using native windows printing is easier than ever.


Let's first take a look at practical applications for barcodes. Barcodes can be used anywhere the software user is required to type in information. They can be used for both numbers and letters. Scanning a barcode instead of typing the information saves time and eliminates mistakes. Barcodes can be used to:

  • Pull up records, including invoices, product descriptions and any forms.
  • Track inventory and packaging.
  • Allow access to personnel (ie. On ID cards)

How To (With NWP):

Using Native Windows Printing, the easiest way to print barcodes is to install a barcode font and then print the barcode using that font. Free barcode fonts can be found online. I use "Free 3 of 9 Extended" by Matthew Welch.

Step 1: Install the barcode font. Here are three possible ways to do so:

  1. ) Install it in the appropriate folder along with your usual install utility.
  2. ) Install it manually on each computer (not recommended).
  3. ) Install it from within the program, using a gosub code that runs once ever, as seen in the example below. The most important code is in bold:
INSTALLFONT: ! The Following If Statement Will Run Once In Order To Install  The Barcode Font
if Exists(":"&Env$("temp")&"\SampleProgram\bcfinst.txt") then
  ! message box
  let Installing=Msgbox("You must install the Barcode Font before printing. Please click INSTALL in the next window to do so. After installation, you may close the window.","Install Font","OK","INF")
  ! Install barcode font
  execute "system start UTILSYSC\fre3of9x.ttf"
  ! create data file to tell program that font is already installed
  open #456: "name=:"&Env$("temp")&"\Sunsoft\bcfinst.txt,new,recl=100",display,output
  print #456: "Barcode font has been installed."
  close #456:
  let Installing2=Msgbox("The Barcode Font is installed.","Finished","OK","INF")
end if

Step 2: Add code to set the font and size. (Using printer.sys shortcuts, SETFONT is "\Efont='FontName'" and SETSIZE is "\E(sPointSizeV").

For example:

print #Printer_Active, using "form C, skip 0": "[SETFONT(Free 3 of 9 Extended)][SETSIZE(38)]"

Step 3: Don't forget the beginning and ending symbols for the barcode, in this font it is an asterisk (*). The barcode scanner uses this to recognize where the information begins and ends.

BARCODEFORM3: form Pos 30,C 1,Cc 6,C 1   
print #Printer_Active, using BARCODEFORM3: "*",INVNR$,"*"

Step 4: Reset your font and size to continue printing regularly.

print #Printer_Active: "[SETFONT(Calibri)][SETSIZE(12)]"

Step 5: Print it. And use your barcode scanner to save time and increase accuracy!

Instead of typing in the information, the scanner inputs the information to your BR program exactly as the keyboard would, no other changes to your program are necessary.

How To (Without NWP):

If your receipt printer does not support NWP, you can use the printer-specific way to print barcodes, as you may well know. Simply refer to the printer's manual (many of which are available online) to get the code required for printing barcodes, and add it to your program.

In my barcode project, the printer used was a Star Micronics heat transfer receipt printer, and I've included the code as an example:

90500     print #Printer_Active: &hex$("1B6204040280")&(INVNR$)&hex$("1E")                  
Remember to include
  1. Escape Sequence, in this example “1B”.
  2. Barcode Specifications, in this case 6204040280, which determines the height, #weight, and spacing of the barcode.
  3. Return sequence, in this example, “1E”.

The barcode starting and ending notation (* in the NWP example) is already included by the printer itself here.