Free Support Forum - aspose.com

Double lines in table in pdf

Hi,
I am trying to achieve double lines for the totals row in table.
can you please let me know how can i do it.

Hello Varsha,

Thanks for using our products.

In order to accomplish your requirements, please try using SetBorderStyle(....) method. Please take a look over the following code snippet in which I have created a sample table with double line border. I have also attached the resultant PDF that I have generated using Aspose.Pdf for .NET 5.2.1. Please take a look. In case it does not satisfy your requirements or you have any further query, please feel free to contact.

[C#]

//Instantiate a Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();
//Create a new section in the Pdf object
Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

//Instantiate a table object
Table tab1 = new Table();
sec1.Paragraphs.Add(tab1);
//Set with column widths of the table
tab1.ColumnWidths = "50 50 50";

//Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);
// specify the border style for cells inside table. It will be displayed as outer border for table cells
tab1.DefaultCellBorder.SetBorderStyle((int)BorderSide.All, Aspose.Pdf.BorderStyle.Double);

//Set table border using another customized BorderInfo object
tab1.Border = new BorderInfo((int)BorderSide.All, 0.1F);
// specify the border style for table. It will be displayed as outer border for table
tab1.Border.SetBorderStyle((int)BorderSide.All, Aspose.Pdf.BorderStyle.Double);

//Create MarginInfo object and set its left, bottom, right and top margins
MarginInfo margin = new MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
//Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin;

//Create rows in the table and then cells in the rows
Row row1 = tab1.Rows.Add();
row1.Cells.Add("col1");
row1.Cells.Add("col2");
row1.Cells.Add("col3");
Row row2 = tab1.Rows.Add();
row2.Cells.Add("item1");
row2.Cells.Add("item2");
row2.Cells.Add("item3");

// add the text paragraph to paragraphs collection of section object
sec1.Paragraphs.Add(tab1);
// save the resultant PDF document
pdf1.Save(@"D:\pdftest\DoubleLineBorder.pdf");