Problem with printing aditional text

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ABPInduction
Newbie
Newbie
Posts: 7
Joined: Fri Dec 23, 2005 12:00 am

Problem with printing aditional text

Post by ABPInduction » Wed Jun 28, 2006 12:46 pm

Dear Support-Team,
I added to my chart aditional text with help of CalcXPosValue, CalcYPosValue and CanVas.TextOut. I'm using Canvas.Font.Size := 10. In the Chart on the windows, everything looks ok, but when I print with help of Chart1.PrintPartialCanvas(Printer.Canvas, Rect(0, 0, Printer.PageWidth,Printer.PageHeight)) the aditional text is so big, that it take all of the paper. How can I add the text, that in both cases the text is as big as the text from the axis.

Thanks
Bent Walther
Developer of ABPInduction Systems GmbH, Dortmund
www.abpinduction.com

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

Post by Narcís » Wed Jun 28, 2006 1:08 pm

Hi Bent,

There are couple of possibilities:

1) If you're printing text, have you used Font.Height instead of Font.Size for font "size" ? This is important because if you are "painting" canvas to printer.canvas then you must use Font.Height (negative value!) to define font "size". Something like this:

Code: Select all

Chart1.Canvas.Font.Height := -11;


For more on Heigh vs. Size check Delphi help file.

2) 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 : Ignore PrintPartialCanvas method and rather 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;
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

ABPInduction
Newbie
Newbie
Posts: 7
Joined: Fri Dec 23, 2005 12:00 am

Post by ABPInduction » Wed Jun 28, 2006 3:21 pm

Thank you very much,
it works perfectly, but I only had the first problem not the second one.
Thank you!

Post Reply