大家好,欢迎来到IT知识分享网。
1. 打印
1.1. 说明
先在软件目录下编译组件,然后引入prints 单元,即可使用。
1.2. 简单说明
以BeginDoc 开始……EndDoc结束,然后开始打印
procedure TForm1.Button2Click(Sender: TObject);
const
LEFTMARGIN = 100; //设置左边页边距
HEADLINE = 'I Printed My Very First Text On '; //要打印的文字
var
YPos, LineHeight, VerticalMargin: Integer;
SuccessString: String;
begin
with printer do
try
BeginDoc;
Canvas.Font.Name:= 'Courier New';
Canvas.Font.Size:=10;
Canvas.Font.Color:=clBlack;
LineHeight:=Round(1.2 * Abs(Canvas.TextHeight('I'))); //设置行高
VerticalMargin:=4*LineHeight;
YPos := VerticalMargin;
SuccessString:=HEADLINE+DateTimeToStr(Now);
Canvas.TextOut(LEFTMARGIN, YPos, SuccessString);
finally
EndDoc;
end;
end;
打印Memo中的文字
procedure TForm1.Button3Click(Sender: TObject);
const
LEFTMARGIN = 100;
var
lines:integer;
YPos, LineHeight, VerticalMargin: Integer;
begin
with printer do
begin
try
BeginDoc;
canvas.font.Name:=memo1.font.Name;
Canvas.Font.Size:=10;
LineHeight:=Round(1.2 * Abs(Canvas.TextHeight('I')));
VerticalMargin:=4*LineHeight;
YPos := VerticalMargin;
for lines:=0 to memo1.Lines.Count-1 do
Canvas.textout(200,1000+LineHeight*Lines,memo1.Lines[lines]);
finally
EndDoc;
end;
end;
end;
]);
finally
EndDoc;
end;
end;
end;
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/15223.html