//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Assign data source.
pdfGrid.DataSource = dataTable;
//Draw grid to the page of PDF document.
PdfLayoutResult result=pdfGrid.Draw(page, new PointF(10, 10));
//Create a PdfGrid.
PdfGrid pdfGrid1 = new PdfGrid();
//Assign data source.
pdfGrid1.DataSource = dataTable1;
//Draw grid to the page of PDF document.
pdfGrid1.Draw(result.Page, new PointF(10, result.Bounds.Height+20));
|
Hello Sowmiya,
This does not resolve my problem. It seems that drawing on the page does not change layout height.
I have:
PdfLayoutResult result = reportTitle.Draw(page, new PointF()); //this is ok. title is on the page
PdfGrid plgrid = new PdfGrid();
DataTable pldt = new DataTable();
PdfGrid plgrid2 = new PdfGrid();
DataTable pldt2 = new DataTable();
...assigning values to the pldt and pldt2
plgrid.DataSource = pldt;
plgrid2.DataSource = pldt2;
PdfGridLayoutFormat layoutFormat = new PdfGridLayoutFormat();
layoutFormat.Layout = PdfLayoutType.Paginate;
plgrid.Draw(result.Page, new PointF(0, result.Bounds.Height + 40)); //this is ok. grid is under title +40
plgrid2.Draw(result.Page, new PointF(0, result.Bounds.Height + 30)); //this is NOT ok. it is drawn under title +30
When I run debug I try to trace result.Bounds values and it is not changing and it seems to be a problem:
var rb = result.Bounds.Bottom;
var rh = result.Bounds.Height;
Hope that sample code can help us to resolve the issue.
Thank You for the initial help.
Regards, Vladimir.
PdfGridLayoutResult result = pdfGrid.Draw(pdfPage, PointF.Empty);
PdfGrid pdfGrid1 = new PdfGrid();
pdfGrid1.DataSource = dataTable1;
PdfGrid pdfGrid2 = new PdfGrid();
pdfGrid2.DataSource = dataTable2;
PdfGridLayoutFormat layoutFormat = new PdfGridLayoutFormat();
layoutFormat.Layout = PdfLayoutType.Paginate;
PdfLayoutResult result1=pdfGrid1.Draw(result.Page, new PointF(0, result.Bounds.Height + 40), layoutFormat);
pdfGrid2.Draw(result1.Page, new PointF(0, result1.Bounds.Height + 30), layoutFormat);
|
How iif secon grid in other page? Probably first grid need more than one page
Hi pudjo,
We have created a sample for adding multiple pdf grids using PdfGridLayoutResult. Drawing of the second grid onto the same page where the first grid was drawn, positioned below the first grid with an offset determined by the first grid's bounds. However, we have attached the sample for your reference. We kindly request you to try it out and let us know if you require any further assistance.
Please find the code snippet below,
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page.
PdfPage page = doc.Pages.Add();
//Create a PdfGrid.
PdfGrid pdfGrid = new PdfGrid();
//Add values to the list. List<object> data = new List<object>(); Object grid1row1 = new { ID = "E01", Name = "Clay", Salary = "$10,000" };
for(int i = 0; i < 75; i++) { data.Add(grid1row1); }
//Add list to IEnumerable. IEnumerable<object> dataTable = data;
//Assign data source.
pdfGrid.DataSource = dataTable;
PdfGridLayoutFormat layoutFormat = new PdfGridLayoutFormat(); layoutFormat.Layout = PdfLayoutType.Paginate;
//Draw grid to the page of PDF document.
PdfGridLayoutResult result = pdfGrid.Draw(page, new PointF(0, 0),layoutFormat);
//Create a PdfGrid.
PdfGrid pdfGrid1 = new PdfGrid();
//Add values to the list. List<object> data1 = new List<object>(); Object grid1Row1 = new { ID = "E01", Name = "Thomas", Salary = "$10,000" };
for(int j= 0; j < 10; j++) { data1.Add(grid1Row1); }
//Add list to IEnumerable. IEnumerable<object> dataTable1 = data1; //Assign data source.
pdfGrid1.DataSource = dataTable1;
PdfLayoutResult result1 = pdfGrid1.Draw(result.Page, new PointF(0, result.Bounds.Bottom + 40), layoutFormat);
doc.Save("Output.pdf"); doc.Close(true); System.Diagnostics.Process.Start("Output.pdf"); |
Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Multiplegrid_Sample-866264740.zip
Regards,
Jeyalakshmi T