formi
asked on
Delphi: how to send PJL commands to printer
Hi
I need to control a printer to staple or punch. For this I have to send PJL-commands to the driver. I found this code:
Thanks, Peter
(the used printerdriver is a HP LaserJet M880 PCL 6)
I need to control a printer to staple or punch. For this I have to send PJL-commands to the driver. I found this code:
type
TPrnBuffRec = record
bufflength: Word;
Buff_1: array[0..1000] of AnsiChar;
end;
function DirectToPrinter(S: ansistring): Boolean;
var
Buff: TPrnBuffRec;
TestInt: integer;
N : cardinal;
begin
Printer.BeginDoc;
TestInt := PassThrough;
if Escape( Printer.Handle, QUERYESCSUPPORT, SizeOf(TESTINT), @testint, nil) > 0 then
begin
StrPCopy(Buff.Buff_1, S);
Buff.bufflength := StrLen(Buff.Buff_1);
Escape(Printer.Canvas.Handle, Passthrough, 0, @buff, nil);
Result := True;
end
else Result := False;
Printer.EndDoc;
end;
To test I call this function and print in a file
DirectToPrinter('HELLO');
I expect that I should find the sent text "HELLO" in this file but I don't. Where can be the problem? Thanks, Peter
(the used printerdriver is a HP LaserJet M880 PCL 6)
ASKER
Thanks. I found that I have to add StartPage and EndPage. Now it works.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is a PCL language description for HP printers... which might help you...