Page 1 of 1

Printing bug for Annotation and Rectangle objects

Posted: Wed Feb 28, 2007 4:35 pm
by 9346307
Hi all,

I found a very annoying printing issue for the Rectangles and Annotations object in TeeChart VCL. It seems that their position is changing between the print preview and the final paper printing. As it was quite hard to send you my paper print, I made some print with my virtual PDF printer : it creates PDF instead of sending the chart to the real printer. Anyway the result is the same in both case (PDF or paper) : there's a discrepancy between the print preview and the print.


Print preview screenshot will all margins set to 10%:
Image

PDF screenshot of the printing with all margins set to 10%:
Image



With further investigations, I found out that the only case where this bug does not occur is when all margins are set to zero.

Print preview screenshot with all margins set to zero:
Image

PDF Screenshot of the printing with all margins set to zero:
Image

Regards,
Kitry

Posted: Fri Mar 02, 2007 11:48 am
by narcis
Hi Kitry,

You should print using StretchDraw as told in this message.

Posted: Mon Mar 05, 2007 10:04 am
by 9346307
in this post, I found the following code :

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject); 
var meta : TMetafile; 
begin 
   Chart1.BevelOuter := bvNone; 
   Meta := Chart1.TeeCreateMetafile(True, Chart1.ClientRect); 
   try 
      [b]Printer[/b].Orientation := [b]poPortrait[/b]; 
      Printer.BeginDoc; 
      try 
         Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth - 1, 
         Printer.PageHeight - 1),Meta); 
      finally 
         Printer.EndDoc; 
      end; 
   finally 
      Meta.Free; 
      Chart1.BevelOuter := bvRaised; 
   end; 
end; 
But if I include this in my application, it raises the following error :

"Undeclared identifier : Printer"
"Undeclared identifier : poPortrait"

Posted: Mon Mar 05, 2007 10:12 am
by narcis
Hi Kitry,

You need to add Printers unit in your form's uses section.

Posted: Mon Mar 05, 2007 10:24 am
by 9346307
Hi NarcĂ­s,

Thanks. I just found it and already made some tests.

Well, this method is not really better. Depending on the printer you're using, the result is for the best only stretched and for the worst mostly unreadable.

Image

I'm sorry but this is really not satisfying for end users. I'm already hearing them complaining about the bad quality of the printing.

Wouldn't it be more accurate to solve the initial print problem that I raised in the beginning of this post ? It doesn't sound unrealistic to me ?

Cheers,
Kitry

Posted: Mon Mar 05, 2007 2:10 pm
by Pep
Hi Kitry,

this problem has been fixed for the next TeeChart Pro v8 (which we're working).
In meantime another solution is to set the correct position based on the paper rect before the Chart is printed, plesae see the code below :

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  if printed then
  begin
    printed := false;
    charttool1.Left:=oldleft;
    charttool1.top:=oldTop;
  end;
end;

procedure TForm1.Chart1BeforePrint(Sender: TCustomTeePanel; Canvas: TCanvas;
  var R: TRect);
begin
  oldleft:=charttool1.Left;
  oldtop:=charttool1.Top;
  ChartTool1.Left:=R.Left+ChartTool1.Left;
  ChartTool1.Top:=R.Top+ChartTool1.Top;
  printed:=true;
end;