Page 1 of 1
How Open Cash Drawer via printer? *working great*
Posted:
Sat Feb 14, 2009 2:37 pm
by dutch
Dear All,
I need to open cash drawer that connect via printer (Epson TM-U220b).
The Cash Drawer is connect via RJ11 connect to printer. I've to send command to printer with FONT NAME 'control' but it must print a piece a paper every time to open.
I try to send command to open it but it do nothing.
What I do wrong?
- Code: Select all Expand view
*------------------*
Function OpenDrawer
local oFnt, oPrinter
PRINTER oPrinter FROM USER
// DEFINE FONT oFnt NAME 'Courier' SIZE 0, -8 OF oPrinter
DEFINE FONT oFnt NAME 'control' SIZE 0, -8 OF oPrinter
// oPrinter:StartPage()
oPrinter:Say( 1, 1, 'A', oFnt )
ENDPRINT
oFnt:End()
return
Regards,
Dutch
Re: How Open Cash Drawer via printer?
Posted:
Sat Feb 14, 2009 2:53 pm
by Otto
Hello Dutch,
this is my code. Maybe it is of some use for you.
Best regards,
Otto
- Code: Select all Expand view
- if GetPvProfString( "Kassenlade", "UEBERDRUCKER" , "N", ".\INI\TOUCH.INI" ) ="J"
- oPrnDOS := TDosPrn():New("LPT1")
- *oPrnDOS:write(chr(27)+chr(112)+chr(15)+chr(15))
- oPrnDOS:write(chr(27)+chr(112)+chr(0)+chr(10)+chr(100))
- oPrnDOS:cFormFeed:="0"
- oPrnDOS:EndPage() // optional
- oPrnDOS:End()
-
- else
-
- oPrn := PrintBegin("DRUCKER", .f., .f.,cPrnName )
- PAGE
- DEFINE FONT oFntNormal NAME "ARIAL" SIZE 16,40
- oPrn:Say( 0,5 , (chr(27)+chr(112)+chr(0)+chr(10)+chr(100)) , oFntNormal )
- ENDPAGE
- ENDPRINT
- RELEASE FONT oFntNormal
-
- ENDIF
-
Re: How Open Cash Drawer via printer?
Posted:
Sat Feb 14, 2009 3:56 pm
by dutch
Thanks Otto, I will try.
Regards,
Dutch
Re: How Open Cash Drawer via printer?
Posted:
Sun Feb 15, 2009 6:28 am
by Richard Chidiak
Dutch
This is my code, note i do not use tdosprn because of usb limitations
HTH
Richard
- Code: Select all Expand view
-
- ICAISSE := GetPvProfString("PRINTER","TICKET",,CINIFile ) // this is the printer you should change to identify yours
- OPRN := TPrinter():New("TEST Impression", .F. , .F. , ICAISSE, .T.)
-
- Ntext := SPACE(45)
- NTEXT := CHR(27) +'p'+ CHR(0)+CHR(10)+CHR(25)
-
- CFILE := "c:\test.TXT" // could be any name
- nHandle := fCreate( cFile )
- FWRITE( nHandle, NTEXT)
- fClose( nHandle )
-
- PrintFileRaw(ICAISSE,CFILE) // this line opens the cash draw
-
- FERASE("C:\test.txt")
-
-
Re: How Open Cash Drawer via printer?
Posted:
Mon Feb 16, 2009 3:55 pm
by Francisco Horta
Richard,
Where is function PrintFileRaw()?
regards
Paco
Re: How Open Cash Drawer via printer?
Posted:
Tue Feb 17, 2009 6:31 am
by Richard Chidiak
Paco
It is a xharbour function
- Code: Select all Expand view
PrintFileRaw()
Prints a file to a Windows printer in RAW mode.
Syntax
PrintFileRaw( <cPrinterName>, ;
<cFileName> , ;
[<cJobTitle>] ) --> nErrorCode
Arguments
<cPrinter>
This is a character string holding the name of the printer to use for printing.
<cFileName>
The file to print must be specified as a character string, including path and extension. If the path is omitted, the file is searched in the current directory.
<cJobTitle>
This is an optional character string which appears as print job description in the spooler. It defaults to <cFileName>. Return
The function returns 1 on success or a value less than zero on error. See the example for error codes.
Description
Function PrintFileRaw() prints a file to a Windows printer in RAW mode. This restricts file types for printing to enhanced metafiles (EMF), ASCII text, and raw data, which includes all printer specific file types such as PostScript and PCL. The file is sent to the Windows spooler which processes the print job. The function returns zero when the file is successfully transferred to the spooler. Note that this is no guarantee for a printout. If the physical printer is out of paper, for example, the spooler reports an error to the user. This type of failure cannot be detected by PrintFileRaw().
Info
See also: GetPrinters(), GetDefaultPrinter(), PrinterExists(), PrinterPortToName()
Category: Printer functions , xHarbour extensions
Source: rtl\tprinter.c
LIB: xhb.lib
DLL: xhbdll.dll
Example
// The example prints a file in RAW mode and demonstrates
// the possible return values of PrintFileRaw().
PROCEDURE Main()
LOCAL cPrinter := GetDefaultPrinter()
LOCAL cFile := "MyFile.Txt"
LOCAL nResult := -1
LOCAL cMsg := "PrintFileRaw(): "
CLS
IF Empty( cPrinter )
? "No default printer found"
QUIT
ENDIF
nResult := PrintFileRaw( cPrinter, cFile, "Test for PrintFileRaw()" )
SWITCH nResult
CASE -1
cMsg += "Invalid parameters passed to function" ; EXIT
CASE -2
cMsg += "WinAPI OpenPrinter() call failed" ; EXIT
CASE -3
cMsg += "WinAPI StartDocPrinter() call failed" ; EXIT
CASE -4
cMsg += "WinAPI StartPagePrinter() call failed" ; EXIT
CASE -5
cMsg += "WinAPI malloc() of memory failed" ; EXIT
CASE -6
cMsg += "File " + cFile + " not found" ; EXIT
DEFAULT
cMsg += cFile + " PRINTED OK!!!"
END
? cMsg
RETURN
Re: How Open Cash Drawer via printer?
Posted:
Tue Mar 03, 2009 7:57 am
by dutch
Dear Otto & Richard,
Otto's samples is working well with 16bits and 32bits
Richard's sample is working weel with 32bits.
Thanks for all of you and kindness,
Dutch
Re: How Open Cash Drawer via printer? *working great*
Posted:
Tue Mar 03, 2009 9:56 pm
by Francisco Horta
thanks richard,
don´t found cause i use harbour
regards
paco