We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to export the Chart to PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

98400 Feb 24,2011 04:56 PM Feb 27,2011 11:59 PM ASP.NET Web Forms (Classic) 4
loading
Tags: Chart
victor elizondo
Asked On February 24, 2011 04:56 PM

Hi guys

I just want to know "How to export a Chart to PDF?". I'm on Visual Basic .Net in C# and I'm using Syncfusion Essential Studio 6.4.0.15. Before of typing this, I tried to find out this theme in the Syncfusion forums, but the links with related information were broken.

Best Regards.




victor elizondo
Replied On February 24, 2011 06:37 PM

I have the code to xport Charts to PDF and it works fine ( this code below the black line), but I still need a lot the help from all of you. I've generated a PDF file with the chart that I have. I need to add to this PDF file a DataTable ( I will worry about this point later, however a little help it's welcome), but mainly I need to know how to make the size of the chart in the PDF a little bit tiny (I want to resize the chart in the PDF) and also add some text to this PDF file.

Besr regards.

_____________________________________________________________
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;

string fileName = @"C:\Users\Victor\Desktop\chartexport";
string exportFileName = fileName + ".pdf";
string file = fileName + ".jpg";
this.ChartWebControl1.SaveImage(file);

//Create a PDF document
PdfDocument pdfDoc = new PdfDocument();

//Add a page to the empty PDF document
pdfDoc.Pages.Add();

//Draw chart image in the first page
pdfDoc.Pages[0].Graphics.DrawImage(Syncfusion.Pdf.Graphics.PdfImage.FromFile(file), new PointF(10, 30));

//Save the PDF Document to disk.
pdfDoc.Save(exportFileName);

// Launches the file.
System.Diagnostics.Process.Start(exportFileName);
_____________________________________________________


Geetha M [Syncfusion]
Replied On February 25, 2011 02:08 AM

Hi Victor,

Thank you for your interest in Syncfusion products.

You can specify the size to which you want to reduce the image as shown in the following code snippet.

pdfDoc.Pages[0].Graphics.DrawImage(Syncfusion.Pdf.Graphics.PdfImage.FromFile(file), new PointF(10, 30), new SizeF(100, 100));

// Write text to the top of the page
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f);
pdfDoc.Pages[0].Graphics.DrawString("Chart exported to PDF", font, PdfBrushes.Black, new PointF(10, 10));

Also, above code snippet shows how to add text to the PDF page.

Please try this and let us know if you have any questions.

Regards,
Geetha


victor elizondo
Replied On February 25, 2011 11:28 AM

Hi Geetha

It works perfectly. A lot of thanks.

Now I will try to research about adding a DATASET into a PDF File. If I don't succeded, I'll be here again.

Regards.


Geetha M [Syncfusion]
Replied On February 27, 2011 11:59 PM

Hi Victor,

Thank you for the update.

Regards,
Geetha


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;