[fpc-pascal] USB Printers
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)
procedure WriteRawStringToPrinter(PrinterName: String; S: String);
if not OpenPrinter(PChar(PrinterName), Handle, nil) then
ShowMessage('error ' + IntToStr(GetLastError));
with DocInfo1 do begin
pDocName := PChar('test doc');
pOutputFile := nil;
pDataType := 'RAW';
StartDocPrinter(Handle, 1, @DocInfo1);
WritePrinter(Handle, PChar(S), Length(S), N);
Roberto Gonçalves Barreiro wrote:
> I'm a delphi programmer.
> I'm printing a report using:
> 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