General information
Category:
Reports & Report designer
>I need to print an barcode into my dos-based printed invoice(that means,printed with @...say commmand).
>
>Because my printer manual said that it provide an couple of control code which can be used to print barcode, I think it is cool,that will remove the complexity on use ActiveX Control or draw bitmap first then print it out.
>
>Yeah, I have checked vfp's help file, and used '???' Command to run these printer control code, like this:
>
>Set Printer on
>Set Device to Printer
>
>@5,5 SAY "BarCode Printer test..."
>
>** My printer is OKI 5340C2
>** And it's print barcode code is :
>** ESC DLE A P1 N1 N2 N3 N4 N5 N6 N7 N8,
>×× ESC DLE B P1 PM DATA
>??? CHR(27) + CHR(16) + CHR(65) + " 8 4 0 0 3 1 1 0 1"
>??? CHR(27) + CHR(16) + CHR(66) + " 24 66" + chr(104) + cBarcodedata
>
>The question is:When the first '???' Command executed, the printer just make an page eject,then do nothing; And there is an print job left in queue and can't go on, Only when i quit vfp, this print job will be remove.
>
>Any suggestion?
>thanks!
Search for RawPrint class, from the readme:
RawPrint.Vcx is a library to allow you to send data, including
printer control characters, to a print queue in raw format.
(without any filtering).
This is needed when printing to a dot matrix printer in
Text Mode, but you want to use the internal printer fonts and
its properties (Bold, condensed, expanded, underlined, etc.)
Allow specifying the Document Name to show in the print queue.
It encapsulate the following API functions:
OpenPrinter()
StartDocPrinter()
EndDocPrinter()
ClosePrinter()
Public methods:
oOpen() - Open and initialize the printer device.
oClose() - Close the printer device, and free the spool.
oPrintFile() - Send the specified file to the print device.
oPrintMem(MVar) - Send content to the print device.
oIsOpen() - Check the status of the print device.
Public Properties:
cFilename - Filename to process in oPrintFile()
cPrinterName - Name of the Windows Printer
cDocName - Document Name to show in the Print Queue
nOpenError - Windows Error number after calling OpenPrinter()
Returned by Win32API GetLastError()
Use :
To print from a memory variable:
Set Classlib to RawPrint Additive
oPrnDev = CreateObject("PrintDev")
oPrnDev.cPrinterName = set('printer', 3)
oPrnDev.cDocName = "Document from Memory var"
If oPrnDev.oOPen()
oPrnDev.PrintMem(MVar1)
* ...
oPrnDev.PrintMem(MVar2)
* ...
oPrnDev.oClose()
Else
* Error opening device; display error number
MessageBox("OpenPrinter() Error: "+str(oPrnDev.nOpenError))
Endif
To print from a file:
Set Classlib to RawPrint Additive
oPrnDev = CreateObject("PrintDev")
oPrnDev.cDocName = "Document from Files"
oPrnDev.cPrinterName = set('printer', 3)
If oPrnDev.oOPen()
oPrnDev.cFilename = 'file1.txt'
oPrnDev.PrintFile()
* ...
oPrnDev.cFilename = 'file2.txt'
oPrnDev.PrintFile()
* ...
oPrnDev.oClose()
Else
* Error opening device; display error number
MessageBox("OpenPrinter() Error: "+str(oPrnDev.nOpenError))
Endif
After the device is opened, you can mix
printing from files and memory.
Legal:
This source code has been released into the public domain.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only