幼
幼虫2004
Unregistered / Unconfirmed
GUEST, unregistred user!
见我的代码:
procedure TForm1.N2Click(Sender: TObject);//新建图形
begin
with form1.Image1do
begin
Width:=1900;
Height:=2770;
canvas.Pen.Color:=clred;
canvas.Pen.Width:=20;
canvas.MoveTo(10,10);
canvas.LineTo(1800,2700);
canvas.Pen.Color:=clblack;
canvas.LineTo(1800,10);
end;
end;
然后打印********************************************************************
procedure TForm1.N5Click(Sender: TObject);//打印
var
AspectRatio:single;
OutputWidth,OutputHeight:Single;
begin
//下面改编自delphi例子,在HP激光打印机中出白纸
if form1.PrintDialog1.Execute then
begin
Printer.begin
Doc;
try
OutputWidth:=image1.Picture.Width;
OutputHeight:=image1.Picture.Height;
AspectRatio:=OutputWidth / OutputHeight;
if (OutputWidth<Printer.PageWidth) and (OutputHeight<Printer.PageHeight) then
begin
if OutputWidth<OutputHeight then
begin
OutputHeight:=Printer.PageHeight;
OutputWidth:=OutputHeight * AspectRatio;
end
else
begin
OutputWidth:=Printer.PageWidth;
OutputHeight:=OutputWidth / AspectRatio;
end
end;
if OutputWidth>Printer.PageWidth then
begin
OutputWidth:=Printer.PageWidth;
OutputHeight:=OutputWidth / AspectRatio;
end;
if OutputHeight>Printer.PageHeight then
begin
OutputHeight:=Printer.PageHeight;
OutputWidth:=OutputHeight * AspectRatio;
end;
Printer.Canvas.StretchDraw(Rect(0,0,Trunc(OutputWidth),Trunc(OutputHeight)),Image1.Picture.Graphic);
finally
Printer.EndDoc;
end;
{printer.begin
Doc;//下面代码改编自大富翁的旧贴,但HP激光打印机只打出白纸
//printer.Canvas.Draw(0,0,form1.Image1.Picture.Graphic;
printer.Canvas.Draw(0,0,Image1.Picture.Bitmap);
printer.EndDoc;}
end;
end;
翻了好多资料,都没解决的方法!!
procedure TForm1.N2Click(Sender: TObject);//新建图形
begin
with form1.Image1do
begin
Width:=1900;
Height:=2770;
canvas.Pen.Color:=clred;
canvas.Pen.Width:=20;
canvas.MoveTo(10,10);
canvas.LineTo(1800,2700);
canvas.Pen.Color:=clblack;
canvas.LineTo(1800,10);
end;
end;
然后打印********************************************************************
procedure TForm1.N5Click(Sender: TObject);//打印
var
AspectRatio:single;
OutputWidth,OutputHeight:Single;
begin
//下面改编自delphi例子,在HP激光打印机中出白纸
if form1.PrintDialog1.Execute then
begin
Printer.begin
Doc;
try
OutputWidth:=image1.Picture.Width;
OutputHeight:=image1.Picture.Height;
AspectRatio:=OutputWidth / OutputHeight;
if (OutputWidth<Printer.PageWidth) and (OutputHeight<Printer.PageHeight) then
begin
if OutputWidth<OutputHeight then
begin
OutputHeight:=Printer.PageHeight;
OutputWidth:=OutputHeight * AspectRatio;
end
else
begin
OutputWidth:=Printer.PageWidth;
OutputHeight:=OutputWidth / AspectRatio;
end
end;
if OutputWidth>Printer.PageWidth then
begin
OutputWidth:=Printer.PageWidth;
OutputHeight:=OutputWidth / AspectRatio;
end;
if OutputHeight>Printer.PageHeight then
begin
OutputHeight:=Printer.PageHeight;
OutputWidth:=OutputHeight * AspectRatio;
end;
Printer.Canvas.StretchDraw(Rect(0,0,Trunc(OutputWidth),Trunc(OutputHeight)),Image1.Picture.Graphic);
finally
Printer.EndDoc;
end;
{printer.begin
Doc;//下面代码改编自大富翁的旧贴,但HP激光打印机只打出白纸
//printer.Canvas.Draw(0,0,form1.Image1.Picture.Graphic;
printer.Canvas.Draw(0,0,Image1.Picture.Bitmap);
printer.EndDoc;}
end;
end;
翻了好多资料,都没解决的方法!!