Printing with other stuff (like a bitmap)

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Paul
Newbie
Newbie
Posts: 20
Joined: Tue Mar 01, 2005 5:00 am

Printing with other stuff (like a bitmap)

Post by Paul » Wed Jul 27, 2005 7:54 pm

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

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

Post by Narcís » Thu Jul 28, 2005 7:45 am

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;
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

Paul
Newbie
Newbie
Posts: 20
Joined: Tue Mar 01, 2005 5:00 am

Post by Paul » Thu Jul 28, 2005 11:26 am

Thanks. Just for completeness, is there any example code showing how to place a chart in a Rave report (at run time)?

Regards

Paul

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

Post by Narcís » Thu Jul 28, 2005 11:55 am

Hi Paul,

You could have a look at the examples at http://www.nevrona.com/Default.aspx?tabid=73 , Rave Reports website.
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

Paul
Newbie
Newbie
Posts: 20
Joined: Tue Mar 01, 2005 5:00 am

Post by Paul » Thu Jul 28, 2005 2:32 pm

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

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

Post by Narcís » Fri Jul 29, 2005 7:42 am

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.
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

Paul
Newbie
Newbie
Posts: 20
Joined: Tue Mar 01, 2005 5:00 am

Post by Paul » Fri Jul 29, 2005 1:01 pm

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

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

Post by Narcís » Fri Jul 29, 2005 1:17 pm

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?
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

Paul
Newbie
Newbie
Posts: 20
Joined: Tue Mar 01, 2005 5:00 am

Post by Paul » Fri Jul 29, 2005 2:08 pm

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

Paul
Newbie
Newbie
Posts: 20
Joined: Tue Mar 01, 2005 5:00 am

Post by Paul » Mon Aug 01, 2005 12:54 pm

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

Post Reply