by this code you will only get the first column of data grid.
string[] str = new string[gridtable.Rows.Count];
for (int i = 0; i < gridtable.Rows.Count; i++)
{
str[i] = gridtable.Rows[i].Cells[0].Value.ToString();
}
PdfTextWidget textWidget = new PdfTextWidget(str.ToString(), font, brush);
to store datagrid data in string you need to store in multidimensional string array.
use below code to fetch all data from datagrid.
string[,] str = new string[gridtable.Rows.Count,gridtable.Columns.Count];
for (int i = 0;i< gridtable.Rows.Count; i++)
{
for(int j=0;j<gridtable.Rows.Count; j++)
{
str[i,j] = gridtable.Rows[i].Cells[j].Value.ToString();
}
}
I haven't used 'PdfTextWidget' but ive used 'iTextsharp' DLL's to create PDF.
You can use the above same looping sequence to write data to PDF from multidimensional string array.