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

adding multiple pdf grids

Thread ID:

Created:

Updated:

Platform:

Replies:

132998 Oct 3,2017 02:14 PM UTC Oct 5,2017 11:14 AM UTC WPF 3
loading
Tags: PDF
Vladimir Culum
Asked On October 3, 2017 02:14 PM UTC

Hello, I am trying to add 2 PdfGrid one after another.

I am adding first one with PdfGridLayoutResult = PdfGrid.Draw(page...)

When I try to add another PdfGrid, it overlaps with first one (if there is multiple pages), because property ...bouds.height is taking height of first grid on last page.

How to add second grid after first one.

Thank You.

Sowmiya Loganathan [Syncfusion]
Replied On October 4, 2017 12:25 PM UTC

Hi Vladimir, 

We can draw PdfGrid one below another. To avoid overlap make sure you have drawn with the resultant page of the first. Please refer the below code snippet for more details. 

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

Please try the code snippet in your end and let us know if it solves your issue. 

Regards, 
Sowmiya L 


Vladimir Culum
Replied On October 4, 2017 10:24 PM UTC

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.


Sowmiya Loganathan [Syncfusion]
Replied On October 5, 2017 11:14 AM UTC

Hi Vladimir, 

We have analyzed with the code snippet provided by you, and modified your code snippet accordingly. 
 
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); 


Please try this in your side and let us know if you need further assistance. 

Regards, 
Sowmiya L 


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

;