Adding more data after an expanded grid on a PDF from scratch

Hi, good day. I have a little trouble with the next case on PDF Document created from scratch.

1.- Create a new pdf doc - done
2.- Create the first page - done
3.- Add Header and footer to pdf doc - done
4.- Add some lines of text using PdfTextElement (up to 10 text lines) - done
5.- Add a grid filled from a database (not draw yet) - done
6.- Re-paginate the doc - done
7.- Drawing the grid using PdfGridLayoutResult - done, the data expands to 9 pages.

My problem begins here.

I need to add more text after the grid, and include several barcodes (3 to 5 barcodes for documment identification, and a QR Code for digital data and website reference). I use the PdfTextString to add the text, but the text prints on the very first page instead of the 9th page after the grid.

I have reviewed the Invoice example given on the software in search for help, but it doesn't includes adding any more data after the grid, so... I am lost.

Is there any example where more elements are written to the PDF document after an expanded grid that I can check? Or do I have to figure how to do that the correct way?

Thanks a lot for your help.

1 Reply

SK Sasi Kumar Sekar Syncfusion Team October 23, 2017 07:04 AM UTC

Hi Juan, 
 
Thank you for contacting Syncfusion support. 
 
The previous drawn element location can be identified by using the PdfGridLayoutResult bounds of Bottom and the final element drawn page can be identified from PdfGridLayoutResult Page properties. 
The text can draw continuous with the PdfGrid using the PdfGridLayoutResult bottom bounds and Page. Using these two properties we can draw text continuous with the PdfGrid. 
 
Please find the simple code snippet to draw the text continuous with the PdfGrid drawn location. 
Code snippet: 
PdfDocument pdfDocument = new PdfDocument(); 
 
PdfPage pdfPage = pdfDocument.Pages.Add(); 
 
//Draw the grid 
PdfGrid pdfGrid = new PdfGrid(); 
 
//Add three columns. 
pdfGrid.Columns.Add(2); 
 
//Add rows. 
for (var i = 0; i < 100; ++i) 
{ 
PdfGridRow pdfGridRow = pdfGrid.Rows.Add(); 
pdfGridRow.Cells[0].Value = "Gilbert"; 
pdfGridRow.Cells[1].Value = "1796"; 
} 
 
//Draw the PdfGrid. 
PdfGridLayoutResult gridResult1 = pdfGrid.Draw(pdfPage, new PointF(0, 0)); 
PdfStandardFont textFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 8); 
PdfTextElement textElement = new PdfTextElement("Text1", textFont, PdfBrushes.Red); 
 
//Drawing string text1 
PdfLayoutResult result = textElement.Draw(gridResult1.Page,new PointF(0,gridResult1.Bounds.Bottom+20)); 
 
//Drawing string text2 
result = textElement.Draw(result.Page, new PointF(0, result.Bounds.Bottom + 20)); 
 
//Drawing string text3 
result = textElement.Draw(result.Page, new PointF(0, result.Bounds.Bottom + 20)); 
 
pdfDocument.Save("sample.pdf"); 
pdfDocument.Close(true); 
 
 
Please check the below KB link to draw the text continuous with the PdfGrid.  
 
In this KB link we have drawn a PdfGrid after completion of another PdfGrid, kindly follow the above KB link to draw the text continuous with the PdfGrid. 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Sasi Kumar S. 


Loader.
Up arrow icon