private void Form1_Load(object sender, EventArgs e)
{
//create a new pdf document
PdfDocument doc = new PdfDocument();
//create new page
PdfPage page = doc.Pages.Add();
Font ffont = new Font("Arial", 6, FontStyle.Regular);
//create a new pdf font
PdfFont font = new PdfTrueTypeFont(ffont,true);
//create a pdfgrid
PdfGrid grid = new PdfGrid();
//add new row to grid
grid.Rows.Add();
//add new column to grid
grid.Columns.Add(10);
PdfGridCellStyle style = new PdfGridCellStyle();
style.Font = font;
grid.Rows[0].Cells[0].Style = style;
//measure the string height
SizeF size = font.MeasureString("Toto jeřetězec, který sycnfusion státy by změna velikosti");
grid.Rows[0].Cells[0].ColumnSpan = 9;
//set the text to grid cell
grid.Rows[0].Cells[0].Value = "Toto jeřetězec, který sycnfusion státy by změna velikosti";
//set color of cell[0] to red
//draw the grid to pdf
grid.Draw(page, PointF.Empty);
//save the pdf document
doc.Save("Pdfgrid.pdf");
//close the document
doc.Close(true);
}
The entire row has red background color as opposed on only cell[0] and cell[1] having white background color