I am importing a datatable with unknown column widths. I import the datatable by setting each column to '300' - more than enough room for the data. However, when using the GetMaxColumnWidth(), it seems to truncate some text. Any ideas where I am going wrong? Or if there is an easier way to set the datatables columns to the proper width? Here is the example of my code:
Pdf pdf1 = new Pdf();
Section sec1 = pdf1.Sections.Add();
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
sec1.Paragraphs.Add(tab1);
for (int i = 0; i <= dt.Columns.Count; i++)
{
string width = " 300 ";
tab1.ColumnWidths += width;
tab1.Title = report.Header.Title;
}
tab1.ImportDataTable(dt, true, 0, 0);
for (int i = 0; i < dt.Columns.Count; i++)
{
tab1.SetColumnWidth(i, tab1.GetMaxColumnWidth(pdf1, i));
}
pdf1.Save("c:\\test.pdf");
Here is a sample of the output to PDF: - the truncated field is in red - should be' Magic Valley Medical Center' - Changing the value of width in the code to '400' or '500' makes no difference.
H61 Clyde Gassert Magic Valley Medical Cent 30057891/23/2010 2:48:57 AMCORPLDRAKEGA11 False False
H61 Clyde Gassert Cassia School Lunch 30105611/23/2010 2:48:57 AMCORPLDRAKEGA11 False False
H61 Clyde Gassert Dietrich School Lunch 30118511/23/2010 2:48:57 AMCORPLDRAKEGA11 False False