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

Free Support Forum - aspose.com

Remove spacing from table border in pdf

Hi Sir/Ma’am
I am getting an error in creating the pdf. I am adding an inner column under an outer column. The outer column is generating through ASpose row and cell but the inner column, I am inserting it into the outer column using HTML.

The problem is, There is some space between the table border and inner column as shown in the image below.

Compliance_Undertaking.PNG (104.7 KB)

The text and HTML are placed in the resource file.
Here is the text

<ol >
<li>Hong Kong Complaints Handling Policy</li>
<li>Hong Kong Professional Investor Policy</li>
<h4 style=" border-bottom:1px solid black; border-top:1px solid black; top:25px; margin-bottom:10px;">Regulators</h4>
<li>Hong Kong Licensing and Registration Policy </li>

Kindly find the attachment to get the c# code.

Aspose Code for Genrating the PDF.zip (3.6 KB)

So how can I remove the space?


Thanks for contacting support.

We have tried to run the code snippet that you have shared but it included some undefined variables and object. However, we have tested the scenario in our environment by creating a sample scenario using HTML string you shared and managed to observe the issue you were facing. You may please set DefaultCellPadding Property of Table as shown in below snippet in order to prevent the mentioned issue.

Document doc = new Document();
Page page = doc.Pages.Add();

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);
Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
tab1.DefaultCellPadding = new MarginInfo(0, 0, 0, 0);
tab1.IsBordersIncluded = false;
tab1.ColumnAdjustment = ColumnAdjustment.AutoFitToContent;
string HTML = @"<ol >
                            <li>Hong Kong Complaints Handling Policy</li>
                            <li>Hong Kong Professional Investor Policy</li>
                            <h4 style='border-bottom:1px solid black;border-top:1px solid black;top: 25px; margin-bottom:10px;'>Regulators</h4>
                            <li>Hong Kong Licensing and Registration Policy</li>
                            </ol> ";
Aspose.Pdf.Row row1 = tab1.Rows.Add();
Cell cell = row1.Cells.Add();
cell.Paragraphs.Add(new HtmlFragment(HTML));
cell.Alignment = HorizontalAlignment.Left;
dataDir = dataDir + "Table_out.pdf";

table_out.pdf (69.5 KB)

For your kind reference, an output PDF document is also attached. In case of any further assistance, please feel free to let us know.