有谁知道chart的打印(100分)(100分)

  • 主题发起人 主题发起人 knightlzf
  • 开始时间 开始时间
K

knightlzf

Unregistered / Unconfirmed
GUEST, unregistred user!
现在想知道怎么把chart的统计图打印出来。最好快点。
 
来自DEMO
type
TPrintForm = class(TForm)
Chart1: TChart;
LineSeries1: TLineSeries;
BitBtn1: TBitBtn;
Edit1: TEdit;
BitBtn2: TBitBtn;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
PrintForm: TPrintForm;
implementation
{$R *.DFM}
uses printers;
procedure TPrintForm.FormCreate(Sender: TObject);
begin
LineSeries1.FillSampleValues(30);
{ <-- we need some random values }
end;

procedure TPrintForm.BitBtn1Click(Sender: TObject);
var h,w:longint;
begin
Screen.Cursor := crHourGlass;
{ <-- nice detail }
try
Printer.begin
Doc;
{ <-- start printer job }
try
{ now print some text on printer.canvas }
With Printer.Canvasdo
begin
Font.Name:='Arial';
Font.Size:=10;
{ <-- set the font size }
Font.Style:=[];
TextOut(0,0,Edit1.Text);
{ <-- print some text }
end;

h:=Printer.PageHeight;
{ <-- get page height }
w:=Printer.PageWidth;
{ <-- get page width }
{ And now print the chart component... }
Chart1.PrintPartial( Rect( w div 10, { <-- left margin }
h div 3 , { <-- top margin }
w - (w div 10), { <-- right margin }
h - (h div 10) ));
{ <-- bottom margin }

{ print more text.... }
With Printer.Canvasdo
begin
Font.Name:='Arial';
Font.Size:=12;
{ <-- set the font size }
Font.Style:=[fsItalic];
TextOut(0,60,Edit1.Text+' ...again');
{ <-- print some text }
end;

Printer.EndDoc;
{ <-- end job and print !! }
except
on Exceptiondo
{ just in case an error happens... }
begin
Printer.Abort;
Printer.EndDoc;
Raise;
{ <-- raise up the exception !!! }
end;
end;
finally
Screen.Cursor:=crDefault;
{ <-- restore cursor }
end;
end;
 
procedure TPrintForm.BitBtn1Click(Sender: TObject);
var h,w:longint;
begin
Screen.Cursor := crHourGlass;
{ <-- nice detail }
try
Printer.begin
Doc;
{ <-- start printer job }
try
{ now print some text on printer.canvas }
With Printer.Canvasdo
begin
Font.Name:='Arial';
Font.Size:=10;
{ <-- set the font size }
Font.Style:=[];
TextOut(0,0,Edit1.Text);
{ <-- print some text }
end;

h:=Printer.PageHeight;
{ <-- get page height }
w:=Printer.PageWidth;
{ <-- get page width }
{ And now print the chart component... }
Chart1.PrintPartial( Rect( w div 10, { <-- left margin }
h div 3 , { <-- top margin }
w - (w div 10), { <-- right margin }
h - (h div 10) ));
{ <-- bottom margin }

{ print more text.... }
With Printer.Canvasdo
begin
Font.Name:='Arial';
Font.Size:=12;
{ <-- set the font size }
Font.Style:=[fsItalic];
TextOut(0,60,Edit1.Text+' ...again');
{ <-- print some text }
end;

Printer.EndDoc;
{ <-- end job and print !! }
except
on Exceptiondo
{ just in case an error happens... }
begin
Printer.Abort;
Printer.EndDoc;
Raise;
{ <-- raise up the exception !!! }
end;
end;
finally
Screen.Cursor:=crDefault;
{ <-- restore cursor }
end;
end;

 
谢谢了!让我试试。
 
打印机好像没反应。
 
我们都试过了,没问题的。
 
多人接受答案了。
 
后退
顶部