Dear Nirmal,
Thanks for your inquiry.
Sorry that there is no way to add PdfTable in a PdfTable cell at present, but PdfGrid can achieve this. And sorry that there is no direct way to insert HTML to PdfGrid cell either, it needs to set the position by yourself according to your requirement.
Here is sample code for your kind reference.
- Code: Select all
PdfDocument pdfdoc = new PdfDocument();
PdfPageBase page = pdfdoc.Pages.Add();
//create one grid as original grid
PdfGrid grid = new PdfGrid();
grid.Columns.Add(2);
PdfGridRow row = grid.Rows.Add();
row.Height = 100;
//create new grid
PdfGrid SubGrid = new PdfGrid();
SubGrid.Columns.Add(1);
SubGrid.Columns[0].Width = 50;
PdfGridRow row2 = SubGrid.Rows.Add();
row2.Height = 20;
row2 = SubGrid.Rows.Add();
row2.Height = 20;
//insert the new grid in the first cell of the first row of the original grid
grid.Rows[0].Cells[0].Value = SubGrid;
//draw the grid on page
grid.Draw(page, new PointF(0, 10));
//draw HTML to the second cell of the first row of the original grid
string HTML = "<p>Hello</p>";
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 20f));
page.Canvas.DrawString(HTML, font, PdfBrushes.Black, grid.Columns[0].Width + 10, 15, true);
pdfdoc.SaveToFile("10380grid.pdf");
Hope this helps. If there is any question, please let me know.
Sincerely,
Betsy
E-iceblue support team