Hello NG
we have the problem do print a TDBChart with custom drawing and text generated by runtime. The Preview looks perfect, everthing is fine until we try to print. The Text on the Chart, generated by TDChart1.canvas,Textout (x,y,'Test'), is not printed correctly.
This is a very important Project with DaimlerChrysler AG Germany, and the Preview Tool is vital to the Project.
Please help.
We are using Delphi 5 Enterprise and Teechart 6 newest Version
Thanks in advance
Michael
Custom Drawing on TDBChart
Hi Michael,
the problem is all custom positioned object (rectangles, text, series
marks) use screen pixels coordinates. While this is fine for screen it does
not work for printer. Why ? The reason for this is if you print, TeeChart
will internally change chart size (so that it fits in specified
printer.Canvas region). The result is Chart size will change but the custom
positioned items "positions" on printer canvas will remain the same (in
screen pixel coordinates). This will result in custom items being drawn at
wrong place. The solution : use the following method to print chart(s):
the problem is all custom positioned object (rectangles, text, series
marks) use screen pixels coordinates. While this is fine for screen it does
not work for printer. Why ? The reason for this is if you print, TeeChart
will internally change chart size (so that it fits in specified
printer.Canvas region). The result is Chart size will change but the custom
positioned items "positions" on printer canvas will remain the same (in
screen pixel coordinates). This will result in custom items being drawn at
wrong place. The solution : use the following method to print chart(s):
Code: Select all
var tmpMeta: TMetaFile;
OldColor : TColor;
begin
Chart1.BevelOuter := bvNone;
OldColor := Chart1.Color;
Chart1.Color := clNone;
tmpMeta := Chart1.TeeCreateMetafile(true,Chart1.ClientRect);
try
Printer.Orientation := poLandscape;
Printer.BeginDoc;
try
Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth - 1,
Printer.PageHeight - 1),tmpMeta);
finally
Printer.EndDoc;
end;
finally
tmpMeta.Free;
Chart1.BevelOuter := bvRaised;
Chart1.Color := OldColor;
end;
end;
Pep Jorge
http://support.steema.com
http://support.steema.com
Custom Drawing on TDBChart
Hi Josep
thank you for the quick reply on my question. I have found this piece of code in the newsgroup and tried it, but i dont get everything printed. It seems that the bottom of the chart where one part of the custom drawing is placed, is not printed or better not a part of chart1.clientrect.
Ive changed the code to Chart1.boundsrect but no effect.
The custom drawing is done in the OnAfterDraw Event of the chart.
Ive gave the Chart a bottom and a top margin, because i have to print a kind of grid beneath the chart and a header ontop of the chart. The header is printed fine, the grid is not printed. The rest of the printout looks ok.
Thanks Michael
thank you for the quick reply on my question. I have found this piece of code in the newsgroup and tried it, but i dont get everything printed. It seems that the bottom of the chart where one part of the custom drawing is placed, is not printed or better not a part of chart1.clientrect.
Ive changed the code to Chart1.boundsrect but no effect.
The custom drawing is done in the OnAfterDraw Event of the chart.
Ive gave the Chart a bottom and a top margin, because i have to print a kind of grid beneath the chart and a header ontop of the chart. The header is printed fine, the grid is not printed. The rest of the printout looks ok.
Thanks Michael
Hi Michael,
as I told you in my other post I'm going to need a simple example with which I can reproduce the problem here.
How are you drawing the Grid on the Canvas ?
as I told you in my other post I'm going to need a simple example with which I can reproduce the problem here.
How are you drawing the Grid on the Canvas ?
Pep Jorge
http://support.steema.com
http://support.steema.com