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.

DataTable passing through a SyncFusion Chart in PDF page

Thread ID:

Created:

Updated:

Platform:

Replies:

98463 Mar 1,2011 06:35 PM Mar 2,2011 10:34 PM ASP.NET Web Forms (Classic) 3
loading
Tags: PDF
victor elizondo
Asked On March 1, 2011 06:35 PM

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";
this.ChartWebControl1.SaveImage(file);
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
pdfDoc.Pages.Add();

//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.
pdfDoc.Save(exportFileName);

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

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.



chartexport_ac975710.rar

Geetha M [Syncfusion]
Replied On March 1, 2011 11:07 PM

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.

Regards,
Geetha


victor elizondo
Replied On March 2, 2011 01:55 PM

Hello

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.

BestRegards



Sample_aa48acde.rar

Geetha M [Syncfusion]
Replied On March 2, 2011 10:34 PM

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.

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.

;