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. Image for the cookie policy date
close icon

How to export the Chart to PDF

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.




4 Replies

VE victor elizondo February 24, 2011 11:37 PM UTC

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



GM Geetha M Syncfusion Team February 25, 2011 07:08 AM UTC

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



VE victor elizondo February 25, 2011 04:28 PM UTC

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.



GM Geetha M Syncfusion Team February 28, 2011 04:59 AM UTC

Hi Victor,

Thank you for the update.

Regards,
Geetha


Loader.
Live Chat Icon For mobile
Up arrow icon