LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Printing to a Citizen CT-S4000 USB Receipt Printer Example

I wasn't able to find an example online on how to print to a USB receipt printer installed as a Windows printer, so I tackled it this morning. Figured I'd share.

 

To send raw ESC/POS data to the printer, I wrote a DLL to handle the WinAPI/WinSpool commands. With docInfo.pDatatype = "RAW"; I can write data directly to the receipt printer. LabVIEW just passes in a printer name and the string data to send to the printer and the DLL talks to the printer. Then I went through the Citizen command reference manual and pulled out any escape codes I thought looked useful into simple VIs. CT-S4000_Print_Raw.vi sends data to the printer using the DLL. Everything else just makes building a big print command string easier.

 

All the example code and documentation is specific to the CT-S4000, but the language ESC/POS should be relatively consistent across different printers. I didn't implement anything too complicated.

 

There's a Citizen_CT-S4000_Example.vi in the LabVIEW folder that prints a short 4-line receipt. The CT-S4000 subfolder contains the DLL and LabVIEW driver VIs. The CodeBlocks folder has the DLL project. The DLL and VIs are in LabVIEW 2019 32-bit.

 

Hope this helps somebody!

0 Kudos
Message 1 of 1
(102 Views)