Print out to the paper center

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
HotSteemar
Newbie
Newbie
Posts: 9
Joined: Wed Nov 19, 2003 5:00 am

Print out to the paper center

Post by HotSteemar » Sat Oct 22, 2005 5:23 am

Hi,
I am trying to print out a chart image on to an A4 paper with some other graphical images, that is, I am trying to lay out several graphical objects on an A4 paper.

The problem is that I can not control the position and size of the TChart object image on the paper. The method available for this purpose seems to be only this one:
void TChart.Draw(System.Drawing.Graphics g)
Paints the Chart in your preferred Canvas and region.
But this method does not accept the position or size argument.
How can I do the size & position control on the paper?
Aren't there method similar to System.Drawing.Graphics.DrawImage?

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

Post by Narcís » Mon Oct 24, 2005 8:11 am

Hi HotSteemar,

You could try doing something like on "All Features\Welcome !\Chart styles\Standard\Pie\Multiple Pies" example at the features demo. You'll find that example on TeeChart's program group.
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

HotSteemar
Newbie
Newbie
Posts: 9
Joined: Wed Nov 19, 2003 5:00 am

Post by HotSteemar » Thu Oct 27, 2005 8:12 am

Hi,
Thank you for the advice, Narcis.
I do not quite understand the example yet.
So, currently what I am doing is like this:

Code: Select all

  private void button1_Click(object sender, System.EventArgs e)
  {
   this.tChart1.Export.Image.Bitmap.Save("temp.bmp");

   //PrintDocument
   System.Drawing.Printing.PrintDocument pd =
    new System.Drawing.Printing.PrintDocument();
   pd.PrintPage +=
    new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage);

   //PrintPreviewDialog
   PrintPreviewDialog ppd = new PrintPreviewDialog();
   ppd.Document = pd;
   //show PrintPreviewDialog
   ppd.ShowDialog();
  }

  private void pd_PrintPage(object sender,
   System.Drawing.Printing.PrintPageEventArgs e)
  {
   //image load
   e.Graphics.DrawString("Here comes a text sample.",
  new Font("MS UI Gothic",10),new
  System.Drawing.SolidBrush(Color.Red),10,10);

  // Here comes a TChart image:
   Image img = Image.FromFile("temp.bmp");
   e.Graphics.DrawImage(img, 100, 100, 600, 600);
   img.Dispose();
  }
Namely, the TChart area is first converted into a bitmap,
then the bitmap is rendered onto the graphics for the printer
by DrawImage() method at the specified location and size.
In this way, several objects can be laid out onto an A4 paper.

This method works well as long as the printer resolution is not
high compared with the resolution of the temporary TChart
bitmap. Otherwise, the printer result shows poor resolution
of the TChart area.

To avoid this awkward situation, I would like to know the way
to render TCharts directly onto graphics with controling the
location and size.
Could I have any more help?

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 Oct 28, 2005 10:54 am

Hi HotSteemar,

You should use a print document as shown on this FAQ's question.
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

HotSteemar
Newbie
Newbie
Posts: 9
Joined: Wed Nov 19, 2003 5:00 am

Post by HotSteemar » Fri Nov 11, 2005 10:20 am

Thank you very much, Narcis.

I could control the position of the serveral objects on the printed papers.
Your advice helped me a lot.

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 Nov 11, 2005 10:41 am

Excellent HotSteemar. You're very welcome.
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

Post Reply