From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-05-2007 08:37 AM
12-06-2007 12:37 AM
I think , difference between using the print command and the CVI PrintTextfile() function is, that the latter uses the windows printer driver system, which usually prepends some setup commands ( i.e for formatting , setting up font etc. ) before sending your command text to the printer, whereas the command line print command just pipes it to the printer without any change.
Windows also provides a Generic/ Text Only printer driver. That driver probably doesn't use any setup for the printer. What happens if you use that printer driver when printing your label ?
12-06-2007 07:37 AM
04-25-2011 08:07 AM
What was your solution to this? I am seeing the same symptom with a Zebra S4M printer, where it is printing the contents of the file or buffer (I have tried it using the PrintTextBuffer function, as well). Fix?
04-26-2011 07:58 AM
Unfortunately there was no fix for this. I ended up using the system command from my original post. My printer has a parallel port so I was stuck using that with the system command. I was never able to get it to work though USB. It looks like the system print command will only dump it to the parallel port.
08-11-2011 09:19 AM
May I ask exactly what label printer are you use? Zebra or Brady?
10-13-2015 01:09 PM
I know this post is quite old but I found a solution that others may find useful. A recent project has required me to send ZPL or EPL commands directly to a label printer again but serial or parallel are no longer an option.
The simplified function below will send the commands directly to the printer (regarless if USB, parallel, etc.) without Windows doing any processing. You will need to make sure there is a CR/LF at the end of each line sent to the printer. This also requires the "windows.h" header and "winspool.dll" available from the Microsoft Windows SDK.
//Will require #include "windows.h" #include "winspool.h" //* Print Label(s) to selected printer ******************************************************************************** int PrintLabel (unsigned char strLabelBuffer[], unsigned char strPrintJobName[], unsigned int uiNumCopies){ unsigned int uiPrinted; int iBytesSent; HANDLE PrintHandle; DOC_INFO_1 DocInfo; if (!OpenPrinter (strLabPrinter, &PrintHandle, NULL)){ //Open printer and get handle MessagePopup ("Printer Error", "Open Printer error!\nCheck Printer selection settings."); return -1; } //Definitions for DOC_INFO_1 DocInfo.pDocName = (LPTSTR)(strPrintJobName); //Print job name DocInfo.pOutputFile = NULL; //NULL = sent to printer DocInfo.pDatatype= (LPTSTR)("RAW"); //RAW = send directly to printer (no processing) if (!StartDocPrinter (PrintHandle, 1, (LPBYTE)&DocInfo)){ //Start print job MessagePopup ("Printer Error", "Could not start Print Job."); return -1; } for (uiPrinted = 0; uiPrinted < uiNumCopies; uiPrinted++){ //Print number of copies requested StartPagePrinter (PrintHandle); //Start "page" WritePrinter (PrintHandle, strLabelBuffer, strlen (strLabelBuffer), &iBytesSent); //Send data to printer EndPagePrinter (PrintHandle); //End "page" } EndDocPrinter (PrintHandle); //End Print Job ClosePrinter (PrintHandle); //Close Printer return 0; }
Hope this helps!