Page 1 of 1
Problem with printing annotations
Posted: Wed Feb 15, 2006 7:21 am
by 9343902
Hi,
printing annotations using the chartpreviewer has still 2 effects.
1. Printing with smoothing --> position of annotations are ok
2. Printing without smoothing --> annotations are print with a negative offset
I've tested this with the "New feature demo".
Can you please help me.
Best Regards
Dirk Zirwes
Posted: Fri Feb 17, 2006 10:19 am
by narcis
Hi Dirk,
The best solution is to use the temporary metafile + StretchDraw method to print charts with custom objects (text, annotation, etc..).
The Rect parameter in StretchDraw defines the drawing rectangle, in this case printer.canvas drawing rectangle.
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, StdCtrls, TeEngine, TeeTools, Series, ExtCtrls, TeeProcs,
Chart,
TeeComma;
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TLineSeries;
ChartTool1: TAnnotationTool;
TeeCommander1: TTeeCommander;
procedure CustomClickEvent(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
Uses Printers;
{$R *.dfm}
procedure TForm1.CustomClickEvent(Sender: TObject);
var tmpMeta: TMetafile;
begin
Chart1.BevelOuter := bvNone;
Chart1.Frame.Visible := False;
tmpMeta := Chart1.TeeCreateMetafile(True,Chart1.ClientRect);
try
Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
Printer.Canvas.StretchDraw(Rect(10,10,Printer.PageWidth -
10, Printer.PageHeight - 10),tmpMeta);
finally
Printer.EndDoc;
end;
finally
tmpMeta.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
TeeCommander1.ButtonPrint.OnClick := CustomClickEvent;
end;
end.