[fpc-pascal] USB Printers
Tom York
tyork at yorkinfo.com
Tue Jul 10 18:13:33 CEST 2007
Since you specify LPT1:, I assume you are using Windows. Obviously the
solution for Linux would be different than Windows. I am not quite sure
about FPC, but in Delphi you basically have two choices.
1) Capture the USB printer to an LPT port, then attempt assign(printer,
'LPTx:'); (not a good solution in my opinion).
2) Open the Windows printer in RAW mode. I've used this style of
printing to a Eltron USB thermal printer and it worked well. The
procedure below is quite similar to the one I used.
Please write back and let me know if this routine works.
(Begin Procedure -- From Delphi newsgroups)
uses WinSpool;
procedure WriteRawStringToPrinter(PrinterName: String; S: String);
var
Handle: THandle;
N: DWORD;
DocInfo1: TDocInfo1;
begin
if not OpenPrinter(PChar(PrinterName), Handle, nil) then
begin
ShowMessage('error ' + IntToStr(GetLastError));
Exit;
end;
with DocInfo1 do begin
pDocName := PChar('test doc');
pOutputFile := nil;
pDataType := 'RAW';
end;
StartDocPrinter(Handle, 1, @DocInfo1);
StartPagePrinter(Handle);
WritePrinter(Handle, PChar(S), Length(S), N);
EndPagePrinter(Handle);
EndDocPrinter(Handle);
ClosePrinter(Handle);
end;
(End Procedure)
Tom
Roberto Gonçalves Barreiro wrote:
> I'm a delphi programmer.
> I'm printing a report using:
> assign(wPrinter,'Lpt1:')
> and it goes ok in paralel priner.
> I did assign(wPrinter,'USB001') and it did not work.
> Do you know how to print in USB printers?
> I thanks a lot if you can help me.
>
More information about the fpc-pascal
mailing list