Hello,
Thank you for your inquiry.
According to your description, I did a preliminary test and reproduced the issue you mentioned. I have logged the issue into our bug tracking system with the ticket number SPIREPDF-5069. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.
In addition, our Spire.PDF supports limiting the width of the Grid, which is more comprehensive and efficient than the table. Please refer to the code below.
- Code: Select all
PdfDocument document = new PdfDocument();
PdfPageBase page = document.Pages.Add();
String[] data = {
"Vendor\r\nName;Address;City",
"Cacor Corporation;161 Southfield Rd;Southfield",
"Underwater;50 N 3rd Street;Indianapolis",
"J.W. Luscher Mfg.;65 Addams Street;Berkely" ,
"E-iceblue; ; "};
//create a grid
PdfGrid grid = new PdfGrid();
//add rows
for (int r = 0; r < data.Length; r++)
{ PdfGridRow row = grid.Rows.Add(); }
//add columns
grid.Columns.Add(3);
//set the width of columns
float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);
grid.Columns[0].Width = 80;
grid.Columns[1].Width = 80;
grid.Columns[2].Width = 80;
//set the height of rows
float height = page.Canvas.ClientSize.Height - (grid.Rows.Count + 1);
grid.Rows[0].Height = 25f;
grid.Rows[1].Height = 12.5f;
grid.Rows[2].Height = 12.5f;
grid.Rows[3].Height = 12.5f;
grid.Rows[4].Height = 12.5f;
//insert data to grid
for (int r = 0; r < data.Length; r++)
{
String[] rowData = data[r].Split(';');
for (int c = 0; c < rowData.Length; c++)
{ grid.Rows[r].Cells[c].Value = rowData[c]; }
}
grid.Rows[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Bold), true);
grid.Draw(page, new PointF(10, 30));
document.SaveToFile("result.pdf", FileFormat.PDF);
Sincerely,
Annika
E-iceblue support team