unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Printers;type TForm1 = class(TForm) Button1: TButton;
PrinterSetupDialog1: TPrinterSetupDialog; Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private { Private declarations } public { Public declarations } end;
var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var prntext:system.text;//将PRNTEXT声名为一个在SYSTEM程序单元当中定义的文本文件begin
if PrinterSetupDialog1.execute then
begin
assignprn(prntext);
//将PRNTEST分配给打印机 rewrite(prntext);
//调用REWRITE函数,为输出打开已分配的文件 printer.canvas.font:=Edit1.font;
//把当前Edit1的字体指定给打印对象的CANVAS的字体属性 Writeln(prntext,Edit1.Text);
Writeln(prntext,Edit2.Text);//把Edit的内容写到打印机对象 system.close(prntext);
//关闭打印文件 end;
end;