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