Pdf table borders missing

Hey -


Have been working with PDF.Generator for a long time and are really happy with it! We use it all over the place to generate pdf output … and version 9.9.0.0 (ours) is WAY WAY faster than older versions.

One little problem that I’m having a hard time figuring out. We are setting the BOTTOM BORDER of a cell to a line, and I am not seeing that border on the printed PDF.

The code to SET the border is below. I swear this used to work before 9.9.0.0, but maybe it never did and I’m just now noticing? Anyway - I’m hoping it’s just cell padding or margin or something.

'Add row headings
Dim cRowHead As Pdf.Generator.Row = MainTbl.Rows.Add()
With cRowHead
For Each [… this is a loop of columns]
With cRowHead.Cells.Add(sTxt, TextInfo)
.Border = New Pdf.Generator.BorderInfo(Pdf.Generator.BorderSide.Bottom, PDFFormat.Header1Color)
.Border.Bottom.LineWidth = .75
End With
Next
End With


** I’ve checked to make sure the variable PDFFormat.Header1Color is set to black, and everything else in the output looks awesome! Just the borders aren’t showing up.

Do table rows or cells need padding/margin in order for borders to show? Is there a table setting that might be messed up that would “hide” borders? Any help would be great!

Hi Brian,

Thanks for your inquiry. I have tested the scenario using new DOM approach to set bottom border and it is working without any issue. Please use new generator for the purpose, it will resolve the issue.

  • [Set border style, Margins and padding of Table(New genertor)](http://www.aspose.com/docs/display/pdfnet/Set+Border+Style%2C+Margins+and+Padding+of+the+Table+%28MergedAPI%29)

Please feel free to contact us for any further assistance.

Best Regards,

So you guys no longer support the PDF.Generator namespace? I ask because switching to the other namespace would mean I rewrite thousands of lines of code … and put it all through QA again/etc.


It’s a very big ask for such a tiny problem. Feels a little bit like maybe you just want to make sure you are actually asking me to do that before you suggest I throw out the code I’ve written with you for the last 5 years?

So - pdf.generator is now deprecated??

Just a quick further note. If I put a border around EVERY cell, it works fine. This problem happens if I have borders (top or bottom) on just the first and last row(s).


Typical data table scenario:

Heading
----------
Data
Data
Data
----------
Total


Hi there,

bsaunders66:
So you guys no longer support the PDF.Generator namespace? I ask because switching to the other namespace would mean I rewrite thousands of lines of code ... and put it all through QA again/etc.

It's a very big ask for such a tiny problem. Feels a little bit like maybe you just want to make sure you are actually asking me to do that before you suggest I throw out the code I've written with you for the last 5 years?

So - pdf.generator is now deprecated??

We are sorry for the inconvenience. Aspose.Pdf.Generator is not depreciated at the moment, however it will be deprecated in near future. We are fixing old generator issues in new generator and adding new features/enhancement in new generator only. As it is more efficient and improved, it can create a PDF from scratch and manipulate existing PDF documents as well.

So it is recommended to migrate to new generator. Almost all object names and functionalities are same except Pdf and Section object these are replaced with Document and Page object respectively. Please find sample code for reference.

//Instntiate the Pdf object by calling its empty constructor

Aspose.Pdf.Document pdf = new Aspose.Pdf.Document();

//Create the section in the Pdf object

Aspose.Pdf.Page sec = pdf.Pages.Add();

//Instantiate a table object

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

//Add the table in paragraphs collection of the desired section

sec.Paragraphs.Add(tab);

//Set with column widths of the table

tab.ColumnWidths = "100 100 100";

//Create header row

Aspose.Pdf.Row rowhead = tab.Rows.Add();

rowhead.Cells.Add("col1");

rowhead.Cells.Add("col2");

rowhead.Cells.Add("col3");

rowhead.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Bottom, 0.1F);

for (int i = 1; i < 6; i++)

{

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

row.Cells.Add("Row" + i + "col1");

row.Cells.Add("Row" + i + "col2");

row.Cells.Add("Row" + i + "col3");

}

//Create footer row

Aspose.Pdf.Row rowfoot = tab.Rows.Add();

rowfoot.Cells.Add("col1");

rowfoot.Cells.Add("col2");

rowfoot.Cells.Add("col3");

rowfoot.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.Top, 0.1F);

//Save the Pdf

pdf.Save(myDir + "TableResultDOM.pdf");


Please feel free to contact us for any further assistance.

Best Regards,
bsaunders66:
Just a quick further note. If I put a border around EVERY cell, it works fine. This problem happens if I have borders (top or bottom) on just the first and last row(s).

Typical data table scenario:

Heading
----------
Data
Data
Data
----------
Total
Hi Brian,

Adding more to Tilal's comments, when using the code snippet based on new Document Object Model (DOM), I am unable to notice any issue and border properly renders for cells inside PDF document. Should you have any further query, please feel free to contact.