on 06-02-2016 2:13 PM
Hi,
we have an EPL output file and need to redirect it to a label printer. How can it be implemented? Over PrintJob or WindowsApi? I 've some test but nothing works yet.
1 Try:
PrintSetPrinter("LABEL_PRINTER")
ulong li_job
li_job = PrintOpen("LABEL_NAME")
print(li_job, "~r~n")
print(li_job,"N~r~n")
print(li_job,"A50,100,0,3,1,1,N"+"Example 3"+ "~r~n")
PrintClose(li_job)
2 Try:
External Functions:
function integer OpenPrinter ( string pPrinterName, ref ulong phPrinter, printer_defaults pDefault ) Library "winspool.drv" ALIAS FOR "OpenPrinter;Ansi"
function integer ClosePrinter ( ulong phPrinter ) Library "winspool.drv"
Function integer EndDocPrinter (Long hPrinter) library "winspool.drv"
Function integer EndPagePrinter (Long hPrinter) library "winspool.drv"
Function integer StartDocPrinter (Long hPtinter, Long Level, DocInfo pDocInfo) library "winspool.drv" ALIAS FOR "StartDocPrinter;Ansi"
Function integer StartPagePrinter (Long hPrinter) library "winspool.drv"
Function integer WritePrinter (Long hPrinter, String pBuf, Long cdBuf, ref Long pcWritten) library "winspool.drv"
$PBExportHeader$docinfo.srs
global type docinfo from structure
integer cbsize
string lpszdocname
string lpszoutput
string lpszdatatype
end type
$PBExportHeader$printer_defaults.srs
global type printer_defaults from structure
long pDataType
long pDevMode
long DesiredAccess
end type
String ls_text, ls_printer
long ll_null, ll_pos
ulong ll_printer
Boolean ll_bol
integer ll_ret,l_doc
docinfo mydocinfo
setnull(ll_null)
printer_defaults pd
pd.desiredaccess = 4
ls_printer="\\PSVM7.HVEA.HEALTHNET.LU\PR890-64"
ll_ret = OpenPrinter(ls_printer,ll_printer,pd)
if ll_ret = 0 then
messagebox("","Error")
else
mydocinfo.lpszdocname="label"
setnull(ls_text)
mydocinfo.lpszoutput=ls_text
mydocinfo.lpszdatatype=ls_text
l_doc=StartDocPrinter(ll_printer,1,Mydocinfo)
StartPagePrinter(ll_printer)
ls_text=""
ls_text= ls_text+ "q3000~r~n"
ls_text= ls_text+ "N~r~n"
ls_text= ls_text+ "A220,5,0,2,1,2,R,XXXXXX~r~n"
ls_text= ls_text+ "A200,43,0,2,1,1,N,XXXX~r~n"
ls_text= ls_text+ "P1~r~n"
ll_ret=WritePrinter(ll_printer,ls_text,len(ls_text),ll_null)
ll_ret=EndPagePrinter(ll_printer)
ll_ret=EndDocPrinter(ll_printer)
ll_ret = ClosePrinter(ll_printer)
end if
Some ideas?
regards
You can use the OpenPrinter function (and it's friends) with no problems, on any print driver.
Suggestions:
- change OpenPrinter declaration to accept LONG for parameter 3, send it a Zero when you call it (it can accept NULL and not need the structure at all)
- remove cbsize from the docinfo structure, it doesn't belong there
- change lpszoutput in docinfo to a long, set it to zero (it's easier than setting a null)
- set lpszdatatype to "RAW"
Define the WritePrinter functions like this:
Function Long WritePrinter(Long Handle, Ref Byte pData[], Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"
Function Long WritePrinter(Long Handle, Ref Char pData[], Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"
Function Long WritePrinterS(Long Handle, Ref String pData, Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"
Use Character arrays when you need to write binary to the printer, and need to compute/plug in values that may end up as binary zero. If you need to read/print a file that has binary in it, read it into a blob, and call WritePrinter with it.
We've been using direct printing like this in one of our applications for about 20 years, and it works fine.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Brad your suggestion helps, here the integration and declaration:
Declarations;
$PBExportHeader$docinfo.srs
global type docinfo from structure
string lpszdocname
long lpszoutput
string lpszdatatype
end type
Local External Functions:
function integer OpenPrinter ( string pPrinterName, ref ulong phPrinter, long pDefault ) Library "winspool.drv" alias for "OpenPrinterW"
function integer ClosePrinter ( ulong phPrinter ) Library "winspool.drv"
Function integer EndDocPrinter (Long hPrinter) library "winspool.drv"
Function integer EndPagePrinter (Long hPrinter) library "winspool.drv"
Function integer StartDocPrinter (Long hPtinter, Long Level, DocInfo pDocInfo) library "winspool.drv" alias for "StartDocPrinterW"
Function integer StartPagePrinter (Long hPrinter) library "winspool.drv"
Function Long WritePrinter(Long Handle, Ref Byte pData[], Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"
Function Long WritePrinter(Long Handle, Ref Char pData[], Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"
Function Long WritePrinterS(Long Handle, Ref String pData, Long pDataLen, Ref Long BytesWritten) Library "winspool.drv" Alias For "WritePrinter;ansi"
Script Print Text:
String ls_printer , ls_texte, ls_Emp_Input, ls_null
long ll_null, ll_pos, ll_doc
ulong ll_printer
integer ll_ret
docinfo mydocinfo
setnull(ll_null)
//printer name
ls_printer="printer_name"
setnull(ls_null)
ll_ret = OpenPrinter(ls_printer,ll_printer,0)
if ll_ret = 0 then
messagebox("","Error")
else
mydocinfo.lpszdocname="Label"
setnull(ls_null)
mydocinfo.lpszoutput=0
mydocinfo.lpszdatatype="Raw" // or set value to ls_null
ll_doc=StartDocPrinter(ll_printer,1,Mydocinfo)
StartPagePrinter(ll_printer)
ls_texte = "N~r~n"
ls_texte +="q416~r~n"
ls_texte +="Q240~r~n"
ls_texte +="A16,4,0,3,1,1,N,~"41272535~"~r~n"
ls_texte +="P1~r~n"
ll_ret=WritePrinterS(ll_printer,ls_texte,len(ls_texte),ll_null)
ll_ret=EndPagePrinter(ll_printer)
ll_ret=EndDocPrinter(ll_printer)
ll_ret = ClosePrinter(ll_printer)
end if
Script Print EPL File:
String ls_printer , ls_Emp_Input, ls_null
long ll_null, ll_doc
ulong ll_printer
integer ll_ret
docinfo mydocinfo
setnull(ll_null)
blob lbl_data
blob lbl_temp
long ll_file
//reading file
lbl_data = blob("")
ll_file = fileopen("C:\EP.EPL",textmode!)
DO WHILE FileReadex(ll_file,lbl_temp) > 0
lbl_data += lbl_temp
LOOP
ls_Emp_Input = string(lbl_data,EncodingANSI!)
FileClose(ll_file)
//printer name
ls_printer="printer_name"
setnull(ls_null)
ll_ret = OpenPrinter(ls_printer,ll_printer,0)
if ll_ret = 0 then
messagebox("","Error")
else
mydocinfo.lpszdocname="Label"
setnull(ls_null)
mydocinfo.lpszoutput=0
mydocinfo.lpszdatatype="Raw" // or set value to ls_null
ll_doc=StartDocPrinter(ll_printer,1,Mydocinfo)
StartPagePrinter(ll_printer)
ll_ret=WritePrinterS(ll_printer,ls_Emp_Input,len(ls_Emp_Input),ll_null)
ll_ret=EndPagePrinter(ll_printer)
ll_ret=EndDocPrinter(ll_printer)
ll_ret = ClosePrinter(ll_printer)
end if
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Depending on the Barcode printer driver you'll need to look at using the Generic Text Driver in windows.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First I would check if the printer is ready to accept Unicode.
If it needs ANSI you have to send blobs to the printer. WritePrinter() accepts these byte arrays.
To convert an Unicode string to an ANSI blob use the blob ( ls_string, EncodingANSI!) function.
hth
Arnd
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marko;
Hopefully, this thread might be of some help ... http://nntp-archive.sybase.com/nntp-archive/action/article/%3C4d776f69$1@forums-1-dub%3E
HTH
Regards ... Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have not used them but based on a quick search, you need to copy the file to the printer. Here is a link that talks about the difference between local and networked printers.
https://www.experts-exchange.com/questions/28124336/copy-epl-file-to-shared-eltron-printer.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.