我的解决办法:
针式打印机的效果应可以了
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
Function Wstring(str:string;SFont:TFont;CWidth,CHeight:integer):TBitMap;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{=====================================================
str:你要打印的字符
SFont:你要的字体
CWidth:你的目标宽度
CHeight:你要的目标高度
=====================================================}
Function TForm1.Wstring(str:string;SFont:TFont;CWidth,CHeight:integer):TBitMap;
var Bmp:TBitmap;
begin
Result:=TBitmap.create;
if length(str)<>0 then
begin
Bmp:=TBitmap.create;
Bmp.Canvas.Font.Assign(SFont);
Bmp.Width:=Bmp.Canvas.TextWidth(str);
Bmp.Height:=Bmp.Canvas.TextHeight('H');
Bmp.Canvas.TextOut(0,0,str);
Result.Width:=CWidth;
Result.Height:=CHeight;
Result.Canvas.StretchDraw(Result.Canvas.ClipRect,Bmp);
Bmp.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
self.Canvas.Draw(50,50,Wstring('1234567890',self.Font,500,90));
self.Button1.Visible:=False;
self.Color:=ClWhite;
self.Print;
self.Button1.Visible:=True;
self.Color:=ClBtnFace;
end;
end.