hello, i have a data table that is bound to an Aspose.Pdf.Generator.Table and I want to underline the column header row which is the first row on the Aspose.Pdf.Generator.Table. Here is my code:
Hi Henry,
Thanks for contacting support.
I have tested the scenario and managed to reproduce the same issue. However, when tested with the new DOM of the Aspose.Pdf namespace, I am unable to notice any problem. For the sake of testing, I have used the following code snippet. Please try using it, and in case you still face the same issue, please share a sample project. We are sorry for your inconvenience.
Please note that all the enhancements and bug fixes are being introduced in the Aspose.Pdf namespace, so it’s recommended to migrate your code to the latest DOM. For your reference, I have also attached the resultant PDF generated on my end.
C#
// Instantiate the Pdf object by calling its empty constructor
Aspose.Pdf.Document pdf1 = new Aspose.Pdf.Document();
// Create the page in the Pdf object
pdf1.Pages.Add();
// Instantiate a table object
Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
// Add the table in paragraphs collection of the desired section
pdf1.Pages[1].Paragraphs.Add(tab1);
// Set column widths of the table
tab1.ColumnWidths = "50 50 50";
// Set default cell border using BorderInfo object
// tab1.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F);
// Set table border using another customized BorderInfo object
// tab1.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 1F);
// Create MarginInfo object and set its left, bottom, right, and top margins
Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.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
Aspose.Pdf.Row row1 = tab1.Rows.Add();
row1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Bottom, 0.5f);
row1.Cells.Add("col1");
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");
// Save the Pdf
pdf1.Save("c:/pdftest/TableResult.pdf");
Hi Nayyer, thank you for the quick response. Can you tell me the differences between the Aspose.Pdf and Aspose.Pdf.Generator namespaces. I wrote most of my code using the objects in the Aspose.Pdf.Generator namespace but I’m having trouble changing the border on specific cells. Please note that I can’t add the rows individually as I’m importing the data directly from the DataTable and I’m using headerfooter and section objects from the Aspose.Pdf.Generator namespace.
Hi Henry,