erm... it only comes with parallel port :'(
I have no problems with accessing the parallel port, but I was just lazy to do a wrapper around all the functions... and thus, wondering if anyone has already done it ;-)
Main Topics
Browse All TopicsHi all,
My current project requires me to perform high-speed barcode printing, so we purchased some high-performance TEC barcode printers.
Unfortunately, these printers do not come with a real driver (that works for Win9x/ME/2K/XP) that prints based on GDI output. Instead, they come with a Programmer's Manual which consists of all the Esc codes to send to the printer (200+ pages of Esc codes!).
Well, I can write a wrapper to it but it will take time and requires testing, so I was wondering if anyone has already done something similar?
DragonSlayer.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well, since you have the escape codes. you can use this code by Joe Hecht. It has been used
to send HP PCL escape codes directly to a printer. The file you print must have the escape
codes embedded in it.
Printing a file directly to a printer in Win32, code by Joe Hecht.
{Note that you have to include WinSpool in the uses clause}
procedure PrintFile(const sFileName: string);
const
BufSize = 16384;
type
TDoc_Info_1 = record
pDocName: pChar;
pOutputFile: pChar;
pDataType: pChar;
end;
var
Count, BytesWritten: integer;
hPrinter: THandle;
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDeviceMode: THandle;
DocInfo: TDoc_Info_1;
f: file;
Buffer: Pointer;
begin
Printer.PrinterIndex := -1;
Printer.GetPrinter(Device,
if not WinSpool.OpenPrinter(@Devi
DocInfo.pDocName := 'MyDocument';
DocInfo.pOutputFile := nil;
DocInfo.pDatatype := 'RAW';
if StartDocPrinter(hPrinter, 1, @DocInfo) = 0 then
begin
WinSpool.ClosePrinter(hPri
exit;
end;
if not StartPagePrinter(hPrinter)
begin
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPri
exit;
end;
Assign(f, sFileName);
Reset(f, 1);
GetMem(Buffer, BufSize);
while not eof(f) do
begin
Blockread(f, Buffer^, BufSize, Count);
if Count > 0 then
begin
if not WritePrinter(hPrinter, Buffer, Count, BytesWritten) then
begin
EndPagePrinter(hPrinter);
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPri
FreeMem(Buffer, BufSize);
exit;
end;
end;
end;
FreeMem(Buffer, BufSize);
EndDocPrinter(hPrinter);
WinSpool.ClosePrinter(hPri
end;
**************************
procedure WriteRawStringToPrinter(Pr
var
Handle: THandle;
N: DWORD;
DocInfo1: TDocInfo1;
begin
if not OpenPrinter(PChar(PrinterN
begin
ShowMessage('error ' + IntToStr(GetLastError));
Exit;
end;
with DocInfo do
begin
pDocName := PChar('test doc');
pOutputFile := nil;
pDataType := 'RAW';
end;
StartDocPrinter(Handle, 1, ocInfo);
StartPagePrinter(Handle);
WritePrinter(Handle, PChar(S), Length(S), N);
EndPagePrinter(Handle);
EndDocPrinter(Handle);
ClosePrinter(Handle);
end;
The PrinterName parameter must be the name of the printer as it is
installed. For example, if the name of the printer
is "HP LaserJet 5MP" then that is what you should pass.
Hey, DragonSlayer,
What model barcode printer?
Here is a post that may also help you:
{
From: "Toni Martir" <toni@NOSPAMpala.com>
Subject: Re: Controlling of print process on dot-matrix printer
Date: Fri, 12 Dec 2003 00:05:57 +0100
Groups: borland.public.delphi.repo
}
To write to lpt1 is a bad idea, it blocs any other process and does not work
if the printer is already procesing a doc, and does not work for a remote
printer, use the print queue instead to send raw data, see bellow.
Or let the reporting engine do all the work for you:
http://reportman.sourcefor
http://reportman.sourcefor
Anyway here is the code you are looking for, this will send a text (with
escape codes if you want) to the printer queue of the current printer
(printerindex) bypassing the printer driver:
procedure SendControlCodeToPrinter(S
var
Handle, hDeviceMode: THandle;
N: DWORD;
DocInfo1: TDocInfo1;
Device, Driver, Port: array[0..255] of char;
PrinterName: string;
buf:pchar;
lbuf:integer;
begin
Printer.GetPrinter(Device,
PrinterName := Format('%s', [Device]);
if not OpenPrinter(PChar(PrinterN
RaiseLastOSError;
try
with DocInfo1 do
begin
pDocName := 'Control';
pOutputFile := nil;
pDataType := 'RAW';
end;
StartDocPrinter(Handle, 1, @DocInfo1);
try
lbuf:=length(s);
buf:=Allocmem(lbuf+2);
try
copymemory(buf,Pchar(s),lb
if not WritePrinter(Handle, buf, lbuf, N) then
RaiseLastOSError;
finally
freemem(buf);
end;
finally
EndDocPrinter(Handle);
end;
finally
ClosePrinter(Handle);
end;
end;
Hi Eddie,
Actually I have all the list of Esc codes for the printer... as I mentioned earlier, the list is quite huge (200+ pages of Esc codes) and I do not have time to code them all in.
I know how to access the printer and send escape codes, but again as I said, I might not have time to code them all in. The Printer is TEC B-572.
I will leave this Q on for another 2-3 days, because by then, I would've finished creating the encapsulation of the ESC codes myself... :'(
Found drivers for that printer here:
http://www.nicelabel.com/d
Thanks Eddie, that is the GDI Driver.
Tests show that it is *indeed slow* and pales in comparison as compared to sending in the codes directly to the printer.
However, since I have already completed coding the class to encapsulate the code sending part, I do not need the GDI driver. I will accept your answer and PAQ it, in case someone else might need this in the future.
Thanks again.
DragonSlayer.
Business Accounts
Answer for Membership
by: delphizedPosted on 2004-03-12 at 23:17:46ID: 10586754
does the printer have a serial port?
I worked with an industrial termal transfer printer that had the serial and it was very quick (5 tag/sec) , it had also the parallel port, but it was slow and buggy... :-)