unit Fileprn;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, Printers;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    OpenDialog1: TOpenDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    Fname: String;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
 if OpenDialog1.Execute then
 begin
  Fname := OpenDialog1.FileName;
  Label1.Caption :=Ready To Print:+ Fname;
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 P,F: TextFile;
 TempStr: String;
begin
 AssignFile(F, Fname);
 Reset(F);
 AssignPrn(P);
 Rewrite(P);
 Label1.Caption :=Now Printing:+ Fname;
  while not Eof(F) do
  begin
   Readln(F, TempStr);
   Writeln(P, TempStr);
  end;
 CloseFile(F);
 CloseFile(P);
 Label1.Caption :=Printing Complete!;
end;

end.