procedure TForm1.Button1Click(Sender: TObject);
var
port, prnfile : File;
buffer: array [1..128] of Char;
read: Integer;
begin
// Specify a file to print
AssignFile(prnfile,'filetoprint');
Reset(prnfile,1);
// specify printer port
AssignFile(port,'LPT1');
Rewrite(port,1);
repeat
BlockRead(prnfile,buffer,SizeOf(buffer),read);
BlockWrite(port,buffer,read);
// Application.ProcessMessages;
until eof(prnfile) or (read <> SizeOf(buffer));
CloseFile(prnfile);
CloseFile(port);
end;