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

Bind datasource to pdfGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

128509 Jan 25,2017 03:52 PM UTC Jan 26,2017 11:13 AM UTC ASP.NET Web Forms 1
loading
Tags: PDF
Keith
Asked On January 25, 2017 03:52 PM UTC

I am trying to bind a datasource to a pdf Grid in .Net Core.

I used the following code from your examples but am recieving an error on the creation of the DataTable, and its properties.

I get the following error: - 'DataTable' does not contain a constructor which takes 0 arguments.

do you have any examples for .Net Core?

//https://help.syncfusion.com/file-formats/pdf/working-with-tables
        public IActionResult PdfGrid(int paperId)
        {
            //Create a new PDF document.

            PdfDocument doc = new PdfDocument();

            //Add a page.

            PdfPage page = doc.Pages.Add();

            //Create a PdfGrid.

            PdfGrid pdfGrid = new PdfGrid();

            //Create a DataTable.
            System.Data.DataTable table = new DataTable();

            //Add columns to the DataTable
            table.Columns.Add("ID");

            table.Columns.Add("Name");

            //Add rows to the DataTable.

            table.Rows.Add(new object[] { "E01", "Clay" });

            table.Rows.Add(new object[] { "E02", "Thomas" });

            //Assign data source.
            pdfGrid.DataSource = table;

            //Draw grid to the page of PDF document.
            pdfGrid.Draw(page, new PointF(10, 10));

            //Saving the PDF to the MemoryStream
            MemoryStream ms = new MemoryStream();
            doc.Save(ms);
            //If the position is not set to '0' then the PDF will be empty.
            ms.Position = 0;

            //Download the PDF document in the browser.
            FileStreamResult fileStreamResult = new FileStreamResult(ms, "application/pdf");
            fileStreamResult.FileDownloadName = "OrderPaper.pdf";

            return fileStreamResult;
        }


Sasi Kumar Sekar [Syncfusion]
Replied On January 26, 2017 11:13 AM UTC

Hi Keith, 
 
Thank you for contacting Syncfusion support. 
 
The DataTable is not compatible with the Asp.NetCore. We can add the PdfGrid values directly without using the DataTable. Please find the online documentation to directly add the values to PdfGrid. 
 
Online documentation to directly add the values to PdfGird. 
 
do you have any examples for .Net Core? 
 
Please add cell values directly using the above online documentation and let us know your feedback. 

Regards, 
Sasi Kumar S. 


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.

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

;