Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Thanx to this forum I have been able to rewrite a touchscreen kiosk application to allow our customers to check themselves in. I am using Winforms, C# and MS-SQL. So far so good.

The original application written in ASP/Javascript and over 8 years old also printed to a POS thermal printer attached to the kiosk. When I print to the same printer with my application, the print out is not even close even though it will print okay to an attached laser printer.

I am exploring the command code documentation that came with the printer but am running into something I've never done before and cannot seem to find in all the Googling I've done. I do not know how I can feed the printer the command codes (ESC codes) needed to make it do what I need it to do. For example, I need to send the printer an Esc code sequence to switch to page mode along with the size of the page where the data will be printed.

Is this possible or do I need to find some other way?

Any advise will be much appreciated.
Posted
Comments
JTRizos 17-Mar-11 21:26pm    
Thanx for prompt responses. I will a dig a bit more and post what I find. Although, I looked at using a string with escape sequences like in solution 2 and was not sure how it will work but will test it. I did look through the available documentation for the printer and the sample code is Basic like the following:

100 PRINT #1, CHR$(&H1B);"L";
110 PRINT #1, CHR$(&H1B);"W";CHR$(0);CHR$(0);CHR$(0);CHR$(0);
120 PRINT #1, CHR$(200);CHR$(0);CHR$(144);CHR$(1);
130 PRINT #1, CHR$(&H1B);"T";CHR$(0);
140 PRINT #1, "Page mode lesson2CAN command";
150 PRINT #1, CHR$(&HA);
160 PRINT #1, "ABCDEFGHIJKLMNOPQRST1234567890";
170 PRINT #1, CHR$(&HC);

Doing this in C# has me stumped. Thanx again.

If you have command code documentation and a printer model, then the first place to look would be for an SDK or API specification from the manufacturer.
 
Share this answer
 
Comments
Espen Harlinn 18-Mar-11 5:29am    
Good advice Marcus - my 5
Sergey Alexandrovich Kryukov 18-Mar-11 14:28pm    
You're right, Marcus, my 5.
The similar projects were discussed here couple of times; and OP argued (or just complained) against manufacturer codes and against normal graphical print (which can be beyond the printer features, this in not your office printer) at the same time. But only the manufacturer is the ultimate source if information. The other problem is that many manufacturers are poor supporters. Then the problem is to a choose of better manufacturer; it happens all the time.
--SA
JTRizos 24-Mar-11 19:02pm    
Well, I did more digging and found that Citizen has a great layout utility for designing forms. They also have a dll available to C# programs that handles the printing to their thermal printers.

Thanx for your help and advise. I learned a lot about printing. Won't take as long next time I need to do this.
Similar discussion here. May help you to get some idea.

Print and send commands to receipt printer[^]
 
Share this answer
 
Comments
Espen Harlinn 18-Mar-11 5:29am    
Nice link - reply reuse, reuse is a good thing - 5ed!
Albin Abel 18-Mar-11 5:47am    
:) Thanks, Espen Harlinn
Sergey Alexandrovich Kryukov 18-Mar-11 14:33pm    
Agree, my 5.
--SA
Albin Abel 18-Mar-11 14:36pm    
Thanks SAKryukov
thatraja 20-Mar-11 7:54am    
It's a good guide man. 5!

BTW why don't you come in GIT(if possible)? you can see our many countrymen there.
http://www.codeproject.com/Forums/1580229/General-Indian-Topics.aspx

Cheers.
You may find the following useful:
http://www.microsoft.com/dynamics/rms/using/oposcontrols.htm[^]

That one, and a bunch of others, can easily be found by leveraging your Google-Fu skills[^]

Regards
Espen Harlinn
 
Share this answer
 
Comments
Albin Abel 18-Mar-11 5:54am    
Yes. Microsoft has an POS extension which uses the OPOS controls. Nice link My 5+
Espen Harlinn 18-Mar-11 5:56am    
Thank you, AlbinAbel
Sergey Alexandrovich Kryukov 18-Mar-11 14:32pm    
Yes, in case the printer supports the standard (which would be the best resolution).
As I mentioned in my comment to the Answer by Marcus, it's the matter of choosing right manufacturer. My 5.
--SA
Well you can build a string containing escape sequences - if you know the number of the character your printer recognises using

\unnnn

where nnnn is the four digit hexadecimal value of the escape character

So you may be able to just build that into the string you are printing.
 
Share this answer
 
Comments
JTRizos 23-Mar-11 17:32pm    
Thanx to everyone but I am still stumped. I read all the links and tried the following:

printLine = lName + ", " + fName + "\n\n" + reasons;

slip = "\u001B"+"L";

slip += "\u001B" + "W" + "\u0030" + "\u0030" + "\u0030" + "\u0030";

slip += "\u0032\u0030\u0030" + "\u0030" + "\u0031\u0034\u0034" + "\u0031";

slip += "\u001B" + "T" + "\u0030" + "\u000A";

slip += printLine; slip += "\u000C\u0004";

This pretty much matches the Basic sample code already posted. It prints to an attached laser pritner as expected but when printing to a CT-S300 thermal printer, it seems to print one line and then does a partial cut continuously thinking there are hundreds of pages to print. It seems the escape sequences have no affect.

Any other ideas will be much appreciated. Thanx again for your advise.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900