Problem with printing annotations

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Dirk
Newbie
Newbie
Posts: 1
Joined: Fri Oct 21, 2005 4:00 am

Problem with printing annotations

Post by Dirk » Wed Feb 15, 2006 7:21 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Feb 17, 2006 10:19 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply