program PRT;
// 20110905 by Thomas Wassermann
{$APPTYPE CONSOLE}
uses
SysUtils,
Windows,
Classes,
Printers;
var
Buffer:
array [0..100000]
of AnsiChar;
BytesRead:cardinal;
sl:TStringList;
Y,i,th,ph:Integer;
begin
try
sl:=TStringList.Create;
try
ReadFile(STD_INPUT_HANDLE , Buffer, 10000, BytesRead,
nil);
sl.Text := sl.text + Copy(Buffer,0,BytesRead);
while BytesRead>0
do
begin
ReadFile(STD_INPUT_HANDLE , Buffer, 10000, BytesRead,
nil);
sl.Text := sl.text + Copy(Buffer,0,BytesRead);
Sleep(100);
end;
if sl.Count>0
then
begin
Printer.BeginDoc;
th := Printer.Canvas.TextHeight('
X');
ph := Printer.PageHeight;
Y := 0;
for I := 0
to sl.Count-1
do
begin
Y := y + th;
if y > ph
then
begin
y := 0;
Printer.NewPage;
end;
Printer.Canvas.TextOut(10, y ,sl[i]);
end;
Printer.EndDoc;
end;
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
finally
sl.Free;
end;
end.