Example Code

Print Barcode from String to any Available Printer Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI prints a BarCode to any available printer available on your PC

 

Description

When this VI runs for the first time, it queries all the available printers on the user's system into a 1D array. Then the user specifies a printer to be used with an index array function and prints the given string as a bar code with the available bar code font. Note that the bar code is not printed from an image, so all the capabilities of the printer are used. In order to use this VI correctly, run this VI once with the 'Printer to Use' control set to 9999 to query all the available printers on the system without printing. Then run a second time with the 'Printer to Use' control set to the number of the desired printer, the Font name set to the Bar code font available on the PC and the 'Barcode to Print' set to the string of the desired Bar code.

 

Requirements

LabVIEW 2012 or compatible

Barcode Font - Download

Link showing how to install fonts on Windows machine

 

Steps to Implement or Execute Code

  1. Run the VI with "Printer to Use" control set to 9999 to query all available printers on your system
  2. Input your desired string to be printed as a barcode
  3. Set the "Printer to Use" control to the number of the desired printer
  4. Set the "Font Name" to the available barcode font on your computer
  5. Run the VI for a second time

Additional Information or References

VI Block Diagram

barcode BD.jpg

 **This document has been updated to meet the current required format for the NI Code Exchange. **

 

Salvador Mikel
National Instruments
Ingeniería de Aplicaciones
www.ni.com/soporte

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
MengHuiHanTang
Active Participant
Active Participant
on

What if the barcode font is not installed on PC, but on printers instead.

I tried your code, but it did not print, I guess it is because LabVIEW requires the font be installed locally before it can print?

dbriggs
Member
Member
on
Make sure the names of the fonts match. If an undefined font is selected then it prints the system(?) default. View the font list via the  'Install Font ...' link provided above.  I had to modify the Font Name from - 'Free 3 of 9' to 'Free 3 of 9 Regular' or 'Free 3 of 9 Extended Regular' in order to obtain proper printing.

Regards, Doug
mimo23
Member
Member
on

hi , i want to print barcode type code 128 how can do it

eastken
Member
Member
on

Thanks for your sharing on printing barcode from string.

But I want to know wether it support printing most linear and 2d barcode?

Hope anyone can tell me. Thanks!

ponkumar
Member
Member
on

Hi,

I have a zebra designer suit for barcode printing. There is possiable to print the barcode from the labview?