hello Friend I have one table in pdf I want to merge some row and want to remove broder of some row what is best idea
Thanks
Shakti
Hello Shakti,
Thanks for considering Aspose.
In order to merge multiple rows of a table you can try using RowSpan property of Cell class. In order to remove the border of a cell, you can try using IsNoBorder property of Cell class and in order to remove the border of a row you can try using DefaultCellBorder property Row class and set BorderSide Enumeration value to None.
Please take a look over the following code snippet, in which border of 3rd row is set to none and row span value for columns in 4th row is set to 2. The resultant file is also in attachment for reference purpose.
[C#]
Pdf pdf = new Pdf();
Aspose.Pdf.Section sec1 = pdf.Sections.Add();
//Instantiate a table object
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
//Add the table in paragraphs collection of the desired section
sec1.Paragraphs.Add(tab1);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
//Set with column widths of the table
tab1.ColumnWidths = "120 120 120";
//Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F,new Aspose.Pdf.Color("Red"));
//Set table border using another customized BorderInfo object
tab1.Border = new BorderInfo((int)BorderSide.All, 1F,new Aspose.Pdf.Color("Blue"));
//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;
Aspose.Pdf.Row row1 = tab1.Rows.Add();
Aspose.Pdf.Cell cell1 = new Aspose.Pdf.Cell(row1);
cell1.Paragraphs.Add(new Text("Column 1" ));
row1.Cells.Add(cell1);
//Create rows in the table and then cells in the rows
row1.Cells.Add("col2");
row1.Cells.Add("col3");
Aspose.Pdf.Row row2 = tab1.Rows.Add();
row2.Cells.Add("item1");
row2.Cells.Add("item2");
row2.Cells.Add("item3");
Aspose.Pdf.Row row3 = tab1.Rows.Add();
// set the default cell border for row as None
row3.DefaultCellBorder = new BorderInfo((int)BorderSide.None);
row3.Cells.Add("item1");
row3.Cells[0].IsNoBorder = true; //Set the border for cell0 as None
row3.Cells.Add("item2");
row3.Cells.Add("item3");
row3.Cells[2].IsNoBorder = true; //Set the border for cell2 as None
Aspose.Pdf.Row row4 = tab1.Rows.Add();
row4.Cells.Add("This is 1st column over 2 Rows");
row4.Cells.Add("This is 2nd column over 2 Rows");
row4.Cells.Add("This is 3rd column over 2 Rows");
row4.Cells[0].RowSpan = 2;
row4.Cells[1].RowSpan = 2;
row4.Cells[2].RowSpan = 2;
pdf.Save(@"d:/pdftest/RowSpan_Border_Test.pdf");