We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

The border does not appear after the first row in a table

Hi! I want a border on top of the last line of my table (ex.: a total line) and I can’t get it to work. This table has no other borders. I have had a lot of issues with borders with version 7.9.0 but I have been able to work around most of them by setting the border of the cells. But I can’t get this particular table to work:

public static void BorderDoesNotAppearAfterFirstRow()
{
Pdf pdf = new Pdf();
pdf.CompressionLevel = 6;
Section section = new Section(pdf);
pdf.Sections.Add(section);
section.IsLandscape = true;

Table table = new Table();
table.ColumnWidths = “130 110”;

Row row = table.Rows.Add();
row.Cells.Add(“XX”);
row.Cells.Add(“XY”);
//AddCellWithBorder(row, “It works for the first row”);
//AddCellWithBorder(row, “but not on the one below!”);

row = table.Rows.Add();
row.Border = BlackTopBorder;
row.DefaultCellBorder = BlackTopBorder;
AddCellWithBorder(row, “Where is my”);
AddCellWithBorder(row, “top border?”);

row = table.Rows.Add();
row.Border = BlackTopBorder;
row.DefaultCellBorder = BlackTopBorder;
AddCellWithBorder(row, “BORDER Y”);
AddCellWithBorder(row, “U NO APPEAR?!”);

section.Paragraphs.Add(table);

string filename = @“d:\TestRowBorders.pdf”;
pdf.Save(filename);
Process.Start(filename);
}
private static void AddCellWithBorder(Row row, string texte)
{
Cell c = row.Cells.Add();
c.Border = BlackTopBorder;
c.Paragraphs.Add(new Text(texte));
}
private static BorderInfo BlackTopBorder { get { return new BorderInfo((int)BorderSide.Top, new Color(“Black”)); } }

Thanks,

Jean-François Rouleau

Hi Jean-François,


Thanks
for using our products.<o:p></o:p>

I have tested the scenario and I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-35244. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Hi Jean-François,


Thanks for your patience.

In order to resolve the problem reported earlier, please try using the following code snippet. For your reference, I have also attached the resultant PDF generated over my end.

[C#]

string outFile = “c:/pdftest/RowBorder_35244.pdf”;<o:p></o:p>

Document doc = new Document();

Page page = doc.Pages.Add();

page.PageInfo.IsLandscape = true;

Aspose.Pdf.Table table = new Aspose.Pdf.Table();

table.ColumnWidths = "130 110";

Aspose.Pdf.Row row = table.Rows.Add();

row.Cells.Add("XX");

row.Cells.Add("XY");

row = table.Rows.Add();

row.Border = BlackTopBorder;

AddCellWithBorder(row, "Where is my");

AddCellWithBorder(row, "top border?");

row = table.Rows.Add();

row.Border = BlackTopBorder;

AddCellWithBorder(row, "BORDER Y");

AddCellWithBorder(row, "U NO APPEAR?!");

page.Paragraphs.Add(table);

doc.Save(outFile);

private static void AddCellWithBorder(Aspose.Pdf.Row row, string texte)

{ Aspose.Pdf.Cell c = row.Cells.Add(); c.Border = BlackTopBorder; c.Paragraphs.Add(new TextFragment(texte)); }

private static Aspose.Pdf.BorderInfo BlackTopBorder

{

get {

return new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Top,2f); }

}

The issues you have found earlier (filed as PDFNEWNET-35244) have been fixed in Aspose.Pdf for .NET 8.2.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.