Page 1 of 1

Printing with other stuff (like a bitmap)

Posted: Wed Jul 27, 2005 7:54 pm
by 9341114
Hello -

I need to be able to print a chart, along with a lot of other stuff, including text, lines, a logo (bitmap) etc. One option available to me is to use Rave (ReportPrinter Pro) but I've not run across any examples on how to do this. Another option is to use the custom drawing feature in TChart7, but will this allow me to include the bitmap and lines? Note that all this needs to happen at run time.

Any assistance will be greatly appreciated.

Thanks

Paul

Posted: Thu Jul 28, 2005 7:45 am
by narcis
Hi Paul,

Yes, you can custom draw text, lines and bitmaps in TeeChart on the OnAfterDraw event using Canvas methods or also you can draw in the TeePreviewPanel as shown in the features demo and the snippet below:

Code: Select all

procedure TForm1.TeePreviewPanel1AfterDraw(Sender: TObject);
var
  img: TBitmap;
begin
  with TeePreviewPanel1,Canvas do
  begin
    Font.Color:=clRed;
    Font.Size:=12;
    TextOut(PaperRect.Left+10,PaperRect.Top+6,'Some text');
    MoveTo(0,0);
    LineTo(100,100);
    img:=TBitmap.Create;
    img.LoadFromFile('C:\temp.bmp');
    Canvas.Draw(50,50,img);
  end;
end;

Posted: Thu Jul 28, 2005 11:26 am
by 9341114
Thanks. Just for completeness, is there any example code showing how to place a chart in a Rave report (at run time)?

Regards

Paul

Posted: Thu Jul 28, 2005 11:55 am
by narcis
Hi Paul,

You could have a look at the examples at http://www.nevrona.com/Default.aspx?tabid=73 , Rave Reports website.

Posted: Thu Jul 28, 2005 2:32 pm
by 9341114
I'm missing something regarding the OnAfterDraw. How is the TeePreviewPanel relalated to chart and/or TChartPreviewer? It appears as a separate object on the form.

Also, in some cases I need to bypass the previewer, and send chart (plus all the other bitmaps, etc) directly to the printer. In effect, I need to disallow modifying the format of the output.

Thanks

Paul

Posted: Fri Jul 29, 2005 7:42 am
by narcis
Hi Paul,
I'm missing something regarding the OnAfterDraw. How is the TeePreviewPanel relalated to chart and/or TChartPreviewer? It appears as a separate object on the form.
Yes, TeePreviewPanel is a separate component however it needs to have a TChart related.
Also, in some cases I need to bypass the previewer, and send chart (plus all the other bitmaps, etc) directly to the printer. In effect, I need to disallow modifying the format of the output.
If you want to skip a preview panel you can also custom draw on the TChart canvas on TChart's AfterDraw event instead of TeePreviewPanel's AfterDraw event.

Posted: Fri Jul 29, 2005 1:01 pm
by 9341114
Still no go. Please let me know if I got this right. In addition to Chart1, I have a TPreviewPanel, property Chart is set to Chart1. I also have a TChartPreviewer whose Chart property is also set to Chart1. Both TChartPreviewer and TPreviewPanel have a AfterDraw event. I've placed TextOut code in both, but neither show when the preview runs, nor when it prints. The chart prints fine. I've placed break points on the events, and the code does break there, but the text does not appear. What am I missing?

Thanks

Paul

Posted: Fri Jul 29, 2005 1:17 pm
by narcis
Hi Paul,

Yes, you got it right. However I meant you could put the custom drawing code at TChart's AfterDraw event as shown here:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues();
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  With Chart1.Canvas do
  begin
    TextOut(Series1.CalcXPos(0),Series1.CalcYPos(0),'First Point');
    TextOut(Series1.CalcXPos(Series1.Count-1),Series1.CalcYPos(Series1.Count-1),'Last Point');
  end;
end;
This code works for me when printing the chart, can you test if it works for you?

Posted: Fri Jul 29, 2005 2:08 pm
by 9341114
Not quite. The text appears on the Chart, and in the Chart previewer, but does not get printed. Also, I need to print outside the margins of the chart. I was using the code from the demos:

Code: Select all

  with TeePreviewPanel1,Canvas do
  begin
    Font.Color:=clRed;
    Font.Size:=12;
    TextOut(PaperRect.Left+10,PaperRect.Top+6,'Some text');
  end;
In either case, I do not get text outside the chart margins.

Paul

Posted: Mon Aug 01, 2005 12:54 pm
by 9341114
I've tested all possible combinations of placing objects in, on, and outside the chart. In every case, the added objects *do not print*. Some of them do, however, show up in the preview. But nothing but the chart on the actual paper.

Please help!

Paul