Page 1 of 1

Unable to print a large TChart

Posted: Fri May 05, 2006 5:41 pm
by 9341746
I m using D7 TChart7.06 TChartPreviewer component to print a graph that
consists of 12 chart axes with one series in each. There are 4000-6000 data
points in each series, with each series having the same number of points.
When I zoom in to display less then 800 hundred points and use
TChartPreviewer to print no problems. As I choose more and more points to
plot the print file gets larger when it gets over about 50-60K things get
slower until finally it will not print when the print file is above arround
100K. I get a printer timeout error. Is there any way to reduce the amount of information going into the print file as with 4000 to 6000 the print file is greater then 1MB.

I have tried Metafiles and straight print of the chart.

The problem exists with all the following printers:

Xerox 8550DP colour workgroup printer, Xerox 6100 colour printer, canon bubblejet printer (MP130), and an B&W HP
Laserjet 4000TN in PCL mode, HP5000

BUT I CAN PRINT ON OUR
OKI DATA color printer

After some more research it seems I can create anything I want in the IDE
with TeeChart and have it print 4 to 5 MB files but from my program I can
not.

Any help would be appreciated.

Posted: Wed May 17, 2006 9:24 am
by narcis
Hi wjec,

The two options for this are the one you already use or printing directly using StretchDraw to.

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.
Also, if the problem only happens in some printers try changing the problematic printers device driver version.