Hi! I have an issue with the border having extra width when using ColumnSpan. The version of Aspose I am using is 8.0. I have attached the resulting PDF. Here is the code:
Hi there,
Thanks for your inquiry. I've managed to reproduce the issue at my end and logged it as PDFNEWNET-35320 in our bug tracking system for further investigation and resolution. You will be notified via this thread as soon as it is resolved.
Sorry for the inconvenience faced.
Hi,
string outFile = “c:/pdftest/TableBorderIssue.pdf”;<o:p></o:p>
Document doc = new Document();
Page page = doc.Pages.Add();
page.Paragraphs.Add(new TextFragment("In all tables below, the LineWidth of the Top border is always specified as 2. "));
page.Paragraphs.Add(new TextFragment("We can also see that the right border overlaps the top border which is pretty ugly/annoying."));
page.Paragraphs.Add(new TextFragment("When the thick border appears, look closely and you will see it overlaps on the left."));
page.Paragraphs.Add(new TextFragment(""));
page.Paragraphs.Add(new TextFragment(""));
page.Paragraphs.Add(new TextFragment("Column span of 4"));
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
table.ColumnWidths = "10% 20% 10% 5% 10% 20% 10% 5% 10%";
table.RepeatingRowsCount = 2;
Aspose.Pdf.Row row = table.Rows.Add();
AddCellWithBackgroundAndBorder(row, "Year", rowSpan: 2);
AddCellWithBackgroundAndBorder(row, "3/4 thin border", colSpan: 4);
AddCellWithBackgroundAndBorder(row, "Thick border! Why?", colSpan: 4);
row = table.Rows.Add();
AddCellWithBackgroundAndBorder(row, "1-1");
AddCellWithBackgroundAndBorder(row, "1-2");
AddCellWithBackgroundAndBorder(row, "1-3");
AddCellWithBackgroundAndBorder(row, "1-4");
AddCellWithBackgroundAndBorder(row, "2-1");
AddCellWithBackgroundAndBorder(row, "2-2");
AddCellWithBackgroundAndBorder(row, "2-3");
AddCellWithBackgroundAndBorder(row, "2-4");
row = table.Rows.Add();
AddCell(row, "2013");
AddCell(row, "2.0");
AddCell(row, "2.1");
AddCell(row, "2.2");
AddCell(row, "2.3");
AddCell(row, "3.0");
AddCell(row, "3.1");
AddCell(row, "3.2");
AddCell(row, "3.3");
page.Paragraphs.Add(table);
page.Paragraphs.Add(new TextFragment(""));
page.Paragraphs.Add(new TextFragment(""));
page.Paragraphs.Add(new TextFragment("Column span of 3 with white divisions"));
table = new Aspose.Pdf.Table();
table.ColumnWidths = "10% 5% 20% 10% 10% 5% 20% 10% 10%";
table.RepeatingRowsCount = 2;
row = table.Rows.Add();
AddCellWithBackgroundAndBorder(row, "Year", rowSpan: 2);
AddCellWithBackgroundAndBorder(row, "", rowSpan: 2, backgroundColor: Aspose.Pdf.Color.White);
AddCellWithBackgroundAndBorder(row, "Thin border", colSpan: 3);
AddCellWithBackgroundAndBorder(row, "", backgroundColor: Aspose.Pdf.Color.White);
AddCellWithBackgroundAndBorder(row, "Thick border on half!?", colSpan: 3);
row = table.Rows.Add();
AddCellWithBackgroundAndBorder(row, "1-1");
AddCellWithBackgroundAndBorder(row, "1-2");
AddCellWithBackgroundAndBorder(row, "1-3");
AddCellWithBackgroundAndBorder(row, "", backgroundColor: Aspose.Pdf.Color.White);
AddCellWithBackgroundAndBorder(row, "2-1");
AddCellWithBackgroundAndBorder(row, "2-2");
AddCellWithBackgroundAndBorder(row, "2-3");
row = table.Rows.Add();
AddCell(row, "2013");
AddCell(row, "", couleur: Aspose.Pdf.Color.White);
AddCell(row, "2");
AddCell(row, "3");
AddCell(row, "3.1");
AddCell(row, "", couleur: Aspose.Pdf.Color.White);
AddCell(row, "4");
AddCell(row, "5");
AddCell(row, "5.1");
page.Paragraphs.Add(table);
page.Paragraphs.Add(new TextFragment(""));
page.Paragraphs.Add(new TextFragment(""));
page.Paragraphs.Add(new TextFragment("Column span of 2 with white divisions"));
table = new Aspose.Pdf.Table();
table.ColumnWidths = "10% 5% 20% 20% 5% 20% 20%";
table.RepeatingRowsCount = 2;
row = table.Rows.Add();
AddCellWithBackgroundAndBorder(row, "Year", rowSpan: 2);
AddCellWithBackgroundAndBorder(row, "", rowSpan: 2, backgroundColor: Aspose.Pdf.Color.White);
AddCellWithBackgroundAndBorder(row, "Thin border", colSpan: 2);
AddCellWithBackgroundAndBorder(row, "", backgroundColor: Aspose.Pdf.Color.White);
AddCellWithBackgroundAndBorder(row, "Finally lost some weight", colSpan: 2);
row = table.Rows.Add();
AddCellWithBackgroundAndBorder(row, "1-1");
AddCellWithBackgroundAndBorder(row, "1-2");
AddCellWithBackgroundAndBorder(row, "", backgroundColor: Aspose.Pdf.Color.White);
AddCellWithBackgroundAndBorder(row, "2-1");
AddCellWithBackgroundAndBorder(row, "2-2");
row = table.Rows.Add();
AddCell(row, "2013");
AddCell(row, "", couleur: Aspose.Pdf.Color.White);
AddCell(row, "2");
AddCell(row, "3");
AddCell(row, "", couleur: Aspose.Pdf.Color.White);
AddCell(row, "4");
AddCell(row, "5");
page.Paragraphs.Add(table);
page.Paragraphs.Add(new TextFragment(""));
page.Paragraphs.Add(new TextFragment(""));
page.Paragraphs.Add(new TextFragment("Column span of 2"));
table = new Aspose.Pdf.Table();
table.ColumnWidths = "10% 20% 25% 20% 25%";
table.RepeatingRowsCount = 2;
row = table.Rows.Add();
AddCellWithBackgroundAndBorder(row, "Year", rowSpan: 2);
AddCellWithBackgroundAndBorder(row, "Thin border", colSpan: 2);
AddCellWithBackgroundAndBorder(row, "Thick border on half?!", colSpan: 2);
row = table.Rows.Add();
AddCellWithBackgroundAndBorder(row, "1-1");
AddCellWithBackgroundAndBorder(row, "1-2");
AddCellWithBackgroundAndBorder(row, "2-1");
AddCellWithBackgroundAndBorder(row, "2-2");
row = table.Rows.Add();
AddCell(row, "2013");
AddCell(row, "2");
AddCell(row, "3");
AddCell(row, "4");
AddCell(row, "5");
page.Paragraphs.Add(table);
doc.Save(outFile);
private static void AddCellWithBackgroundAndBorder(Aspose.Pdf.Row row, string text, int colSpan = 1, int rowSpan = 1, Aspose.Pdf.Color backgroundColor = null)
{
Aspose.Pdf.Cell c = row.Cells.Add();
c.BackgroundColor = backgroundColor ?? Aspose.Pdf.Color.FromRgb(System.Drawing.Color.FromArgb(77, 108, 130));
c.RowSpan = rowSpan;
c.ColSpan = colSpan;
c.Border = new Aspose.Pdf.BorderInfo();
CellBorderStyle topStyle = new CellBorderStyle();
c.Border.Top = topStyle;
topStyle.LineWidth = 2;
topStyle.Color = Aspose.Pdf.Color.White;
CellBorderStyle rightStyle = new CellBorderStyle();
c.Border.Right = rightStyle;
rightStyle.LineWidth = 1;
rightStyle.Color = Aspose.Pdf.Color.White;
c.Paragraphs.Add(new TextFragment(text));
}
private static Aspose.Pdf.Cell AddCell(Aspose.Pdf.Row row, string text, int colSpan = 1, int rowSpan = 1, Aspose.Pdf.Color couleur = null)
{
Aspose.Pdf.Cell cell = row.Cells.Add(text); cell.RowSpan = rowSpan; cell.ColSpan = colSpan;
if (couleur != null)
{
cell.BackgroundColor = couleur;
}
return cell;
}
The issues you have found earlier (filed as PDFNEWNET-35320) have been fixed in Aspose.Pdf for .NET 8.2.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.