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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DataTable passing through a SyncFusion Chart in PDF page

Thread ID:





98463 Mar 1,2011 11:35 PM UTC Mar 3,2011 03:34 AM UTC ASP.NET Web Forms (Classic) 3
Tags: PDF
victor elizondo
Asked On March 1, 2011 11:35 PM UTC

Hi guys

I've attached a PDF file generated by the code below:
string fileName = @"C:\Users\xportal42\Desktop\chartexport";
string exportFileName = fileName + ".pdf";
string file = fileName + ".jpg";
Font f = new Font("Calibri", 12f, FontStyle.Bold);
PdfFont pdfFont = new PdfTrueTypeFont(f);

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

//Add a page to the empty PDF document

//Draw chart image and add some text and datatable in the first page
pdfDoc.Pages[0].Graphics.DrawString("General Information", pdfFont, new PdfSolidBrush(new PdfColor(213, 123, 19)), 25, 5);
pdfDoc.Pages[0].Graphics.DrawString("Education Grade", pdfFont, new PdfSolidBrush(new PdfColor(213, 123, 19)), 200, 5);

// Creating table
PdfLightTable table = new PdfLightTable();
PdfPage page = pdfDoc.Pages[0];
table.DataSourceType = PdfLightTableDataSourceType.External;
// Initializing datasource
table.DataSource = Session["DataToGraphicPDF"] as DataTable;
//table.DataSource = dataTable;
//Set layout properties
PdfLayoutFormat format = new PdfLayoutFormat();
format.Break = PdfLayoutBreakType.FitElement;
format.Layout = PdfLayoutType.Paginate; /////
// Drawing Table
table.Draw(page, new PointF(10,100), format);

pdfDoc.Pages[0].Graphics.DrawImage(Syncfusion.Pdf.Graphics.PdfImage.FromFile(file), new Point(200, 200), new Size(200, 200));

//Save the PDF Document to disk.

//Launches the file.

As you can see PDF file, the dataTable pass through a SyncFusion Chart. How can I solve this? Because the datatable has a variable size (could have over 1000 rows!!!) and all I need is while the dataset grows, the syncfusion stays under the datatable.

Best Regards.


Geetha M [Syncfusion]
Replied On March 2, 2011 04:07 AM UTC

Hi Victor,

Thank you for the details.

Drawing table returns PdfLightTableLayoutResult with the bounds of the table drawn. You can calculate the new point for the image from that result. Please refer to the code snippet below.

PdfLightTableLayoutResult result = table.Draw(page, new PointF(10, 100), format);
PointF pt = new PointF(result.Bounds.X, result.Bounds.Bottom + 10);
result.Page.Graphics.DrawImage(PdfImage.FromFile(file), pt, new Size(200, 200));

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


victor elizondo
Replied On March 2, 2011 06:55 PM UTC


Thanks again. Everything it's ok. The only difference in the code that you provide me is this one:

PdfLightTableLayoutResult result = table.Draw(page, new PointF(10, 100), format) as PdfLightTableLayoutResult;

I have a doubt about something but I guess I must post it in another theme.



Geetha M [Syncfusion]
Replied On March 3, 2011 03:34 AM UTC

Hi Victor,

Thank you for the update.

Glad to hear that the code snippet worked for you.

Please let us know if you have any other questions.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon