emiliodabdoub
asked on
Send Cut Command to POS printer.
I have a Star Micronics SP300 (POS) printer. It is installed as a
windows printer with Generic Text Only drivers. I'm using RawPrinter
Helper Class to
send data to the printer. See: http://support.microsoft.com/?id=322090
. It works correctly printing the text.
My only problem is that this printer has an AutoCuter feature (to cut
the ticket paper) but to make it work, I have to send a special code
to the printer.
I tried using the SendStringToPrinter method from the
rawprinteerhelper class (VB.NET), but it did not work.
I need to make this printer cut the paper under VB.NET (with
the printer installed under windows).
One problem is that this printer is serial (COM1) so, I cannot just
open the port and send the data because when it is installed as a
printer, the com1 is under exclusive access by windows. And also the
OPOS driver that has a function to send the cut command does not work
if the printer is installed in windows.
I think that a solution would be to use SendBytesToPrinter from
Rawprinterhelper class, but I just dont know how this function works.
A few Reference URL's you can find useful:
http://return.no-ip.org/n54/index49/1013655327.html
http://www.starmicronics.com/printers/printers_pages/support/programming.html
Also download the Developer guides from starmicronics.com to see a
complete code reference.
windows printer with Generic Text Only drivers. I'm using RawPrinter
Helper Class to
send data to the printer. See: http://support.microsoft.com/?id=322090
. It works correctly printing the text.
My only problem is that this printer has an AutoCuter feature (to cut
the ticket paper) but to make it work, I have to send a special code
to the printer.
I tried using the SendStringToPrinter method from the
rawprinteerhelper class (VB.NET), but it did not work.
I need to make this printer cut the paper under VB.NET (with
the printer installed under windows).
One problem is that this printer is serial (COM1) so, I cannot just
open the port and send the data because when it is installed as a
printer, the com1 is under exclusive access by windows. And also the
OPOS driver that has a function to send the cut command does not work
if the printer is installed in windows.
I think that a solution would be to use SendBytesToPrinter from
Rawprinterhelper class, but I just dont know how this function works.
A few Reference URL's you can find useful:
http://return.no-ip.org/n54/index49/1013655327.html
http://www.starmicronics.com/printers/printers_pages/support/programming.html
Also download the Developer guides from starmicronics.com to see a
complete code reference.
With the POS Driver try to do this...
' PAPER CUT - PARTIAL CUT
POSPrinter1.PrintNormal PTR_S_RECEIPT, Chr$(27) + "|99P"
' PAPER CUT - FULL CUT
POSPrinter1.PrintNormal PTR_S_RECEIPT, Chr$(27) + "|100P"
' FEED TO THE CUTTING POSITION AND THEN CUT
POSPrinter1.PrintNormal PTR_S_RECEIPT, Chr$(27) + "|fP"
' PAPER CUT - PARTIAL CUT
POSPrinter1.PrintNormal PTR_S_RECEIPT, Chr$(27) + "|99P"
' PAPER CUT - FULL CUT
POSPrinter1.PrintNormal PTR_S_RECEIPT, Chr$(27) + "|100P"
' FEED TO THE CUTTING POSITION AND THEN CUT
POSPrinter1.PrintNormal PTR_S_RECEIPT, Chr$(27) + "|fP"
ASKER
Jan:
I compiled and ran the MSDN sample as I posted in the question. I can print with the sendstring to printer which at the same time uses sendbutestoprinter.
My problem is that if I use: sendStringtoprinter( CHR$(27) & CHR$(100); & CHR$(51))
it just dont make anything.
In the programming samples comes a sample in VB6 with: Print #1, CHR$(27) ; CHR$(100); ; CHR$(51)
but I dont know if it is the same as concatenating with &, they use a ;
and also they open the port directly, not using the printer drivers.
TeddyZero:
As I stated on the question I cant use the Opos Drivers because the printer is installed as a window printer.
I compiled and ran the MSDN sample as I posted in the question. I can print with the sendstring to printer which at the same time uses sendbutestoprinter.
My problem is that if I use: sendStringtoprinter( CHR$(27) & CHR$(100); & CHR$(51))
it just dont make anything.
In the programming samples comes a sample in VB6 with: Print #1, CHR$(27) ; CHR$(100); ; CHR$(51)
but I dont know if it is the same as concatenating with &, they use a ;
and also they open the port directly, not using the printer drivers.
TeddyZero:
As I stated on the question I cant use the Opos Drivers because the printer is installed as a window printer.
Emilio,
thanks for the explanation. So, first we have to find out whether the printer accepts input from SendStringToPrinter. To do so, we could just send a long string of text:
Dim s as String
s = "The quick brown fox jumps over the lazy dog" & CHR(13) & CHR(10).
sendStringtoprinter(s)
sendStringtoprinter(s)
sendStringtoprinter(s)
sendStringtoprinter(s)
sendStringtoprinter(s)
This should print five lines. Can you try this, please?
Jan
thanks for the explanation. So, first we have to find out whether the printer accepts input from SendStringToPrinter. To do so, we could just send a long string of text:
Dim s as String
s = "The quick brown fox jumps over the lazy dog" & CHR(13) & CHR(10).
sendStringtoprinter(s)
sendStringtoprinter(s)
sendStringtoprinter(s)
sendStringtoprinter(s)
sendStringtoprinter(s)
This should print five lines. Can you try this, please?
Jan
ASKER
yes, it printed 5 lines..
Excellent - this means that sendStringToPrinter works as expected.
According to http://www.starmicronics.com/printers/printers_pages/support/programming.html, the CUT command sequence is as follows:
' FEED TO CUT POSITION THEN PERFORM PARTIAL CUT ( ONLY WORKS WITH PRINTERS THAT HAVE AUTO
' CUTTING CAPABILITY)
' IF PRINTER DOES NOT HAVE FULL CUT CAPABILITY, PARTIAL CUT WILL BE PERFORMED
' CMD: <ESC> "d" "3"
' PRINT #1, CHR$(27); CHR$(100); CHR$(51);
So, this translates to
SendStringToPrinter(CHR(27 ) & "d3")
Can you try this?
If it doesn't work, add a CR/LF:
SendStringToPrinter(CHR(27 ) & "d3" & CHR(13) & CHF(10))
Jan
According to http://www.starmicronics.com/printers/printers_pages/support/programming.html, the CUT command sequence is as follows:
' FEED TO CUT POSITION THEN PERFORM PARTIAL CUT ( ONLY WORKS WITH PRINTERS THAT HAVE AUTO
' CUTTING CAPABILITY)
' IF PRINTER DOES NOT HAVE FULL CUT CAPABILITY, PARTIAL CUT WILL BE PERFORMED
' CMD: <ESC> "d" "3"
' PRINT #1, CHR$(27); CHR$(100); CHR$(51);
So, this translates to
SendStringToPrinter(CHR(27
Can you try this?
If it doesn't work, add a CR/LF:
SendStringToPrinter(CHR(27
Jan
... and if this doesn't work, can you try
SendStringToPrinter(Chr$(2 7) & "|100P")
... and if this doesn't work, can you try
SendStringToPrinter(Chr$(2 7) & "|100P" & CHR(13) & CHR(10))
The documentation is not consistent about the CUT command, so we'll have to experiment.
Jan
SendStringToPrinter(Chr$(2
... and if this doesn't work, can you try
SendStringToPrinter(Chr$(2
The documentation is not consistent about the CUT command, so we'll have to experiment.
Jan
ASKER
Hi, I spent 2 hours researching, and found a lot of users with the same problem, it is incredible that nobody has the answer to this. To mention just a few URL's :
http://www.dotnet247.com/247reference/msgs/7/35188.aspx
http://www.mail-archive.com/vb_dotnet@p2p.wrox.com/msg00488.html
http://www.dotnet247.com/247reference/msgs/24/121212.aspx
I already tried that, I found that the data passed that way is called Escale Sequences, and maybe they cant be sent as a plain String.
I found an interesting answer to a user here in experts exchange with teh same problem. The problem is that I dont know C++
check: https://www.experts-exchange.com/questions/10163890/printer-control-code.html?query=control+codes+printer&clearTAFilter=true
Check the accepted answer.
http://www.dotnet247.com/247reference/msgs/7/35188.aspx
http://www.mail-archive.com/vb_dotnet@p2p.wrox.com/msg00488.html
http://www.dotnet247.com/247reference/msgs/24/121212.aspx
I already tried that, I found that the data passed that way is called Escale Sequences, and maybe they cant be sent as a plain String.
I found an interesting answer to a user here in experts exchange with teh same problem. The problem is that I dont know C++
check: https://www.experts-exchange.com/questions/10163890/printer-control-code.html?query=control+codes+printer&clearTAFilter=true
Check the accepted answer.
ASKER
sorry, not Escale Sequences, it is Escape Sequences.. and I tried all your samples in the past. That is why I'm here :)
ASKER
I found this:
this explains and resolves the problem, jus tell me how to implement it in VB.NET (through interop or anyway is good!) and you get the points
this explains and resolves the problem, jus tell me how to implement it in VB.NET (through interop or anyway is good!) and you get the points
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YES!!! it prints in Underlines!!!
Damn, why it dont cut the paper?
Damn, why it dont cut the paper?
ASKER
Maaaaan! you are the maaaaaaan! hahahahahahah
It worked! at last! I'm so happy!!!!
I got the Hex codes from the programmers manual...
CutPaper = ESC & Chr(&H64) & Chr(&H31)
Holy....
You have the points..
Many Thanks!!!
I can sleep now!!! zzzZZZzz
It worked! at last! I'm so happy!!!!
I got the Hex codes from the programmers manual...
CutPaper = ESC & Chr(&H64) & Chr(&H31)
Holy....
You have the points..
Many Thanks!!!
I can sleep now!!! zzzZZZzz
Because the ESC sequence was wrong or incomplete.
Let's check in the manual again:
Trigger auto-cutter drive (Auto-cutting models only)
<ESC> “d” “0” or <ESC> “d” <0> (1B)H (64)H (30)H or (1B)H (64)H (00)H
<ESC> “d” “1” or <ESC> “d” <1> (1B)H (64)H (31)H or (1B)H (64)H (01)H
OUTLINE This code causes the printer to trigger auto-cutter.
I do not understand why there are two ESC sequences, so we'll have to experiment.
Try to add the following code:
...
Dim Autocut1 as String
Dim Autocut2 as String
Autocut1 = ESC & Chr(&H64) & Chr(&H30)
Autocut2 = ESC & Chr(&H64) & Chr(&H31)
...
SendStringToPrinter("Befor e Autocut1" & CR & LF)
SendStringToPrinter(Autocu t1)
SendStringToPrinter("After Autocut1" & CR & LF)
SendStringToPrinter("Befor e Autocut2" & CR & LF)
SendStringToPrinter(Autocu t2)
SendStringToPrinter("After Autocut2" & CR & LF)
What happens now? It should cut twice...
Let's check in the manual again:
Trigger auto-cutter drive (Auto-cutting models only)
<ESC> “d” “0” or <ESC> “d” <0> (1B)H (64)H (30)H or (1B)H (64)H (00)H
<ESC> “d” “1” or <ESC> “d” <1> (1B)H (64)H (31)H or (1B)H (64)H (01)H
OUTLINE This code causes the printer to trigger auto-cutter.
I do not understand why there are two ESC sequences, so we'll have to experiment.
Try to add the following code:
...
Dim Autocut1 as String
Dim Autocut2 as String
Autocut1 = ESC & Chr(&H64) & Chr(&H30)
Autocut2 = ESC & Chr(&H64) & Chr(&H31)
...
SendStringToPrinter("Befor
SendStringToPrinter(Autocu
SendStringToPrinter("After
SendStringToPrinter("Befor
SendStringToPrinter(Autocu
SendStringToPrinter("After
What happens now? It should cut twice...
Thanks for the points and good luck to you.
Jan
Jan
ASKER
just for curiosity..
Why char(27) & "d3" was not working?
Why char(27) & "d3" was not working?
I think ESC & "d3" is not valid. Valid codes are ESC & "d0" and ESC & "d1" according to the docs.
Jan
Jan
ASKER
damn.. right.
I tested and it works..
I should sue them.. they took about 10 hours of my time :@
I tested and it works..
I should sue them.. they took about 10 hours of my time :@
Well, escape code can and do vary from manufacturer to manufacturer and from model to model. So, ESC & "d3" may work for model 299, but not 300...
I understand this is an old question, but i am facing the same problem now! The only difference is my POS printer is Wincor Nixdorf ND69. I am using Windows NT Generic/Text Only Driver, and i have to use JAVA but not VB to code the ESC Sequence. The ESC sequece to CUT Receipt is <1B>H <69>H . Can anybody tell me how can i make it works???
CHR$(27) & CHR$(100); & CHR$(51)
to the printer. So the only problem is how to use the SendBytesToPrinter sample from MSDN.
I assume you have copied all the sample code from MSDN, is that right? What doesn't work? Compiler errors? Or run-time errors?
Jan