Insert HTML String in Word Document & Retain Formatting of Table Borders when Converting to PDF using C# .NET

ASPOSE TBL Border styles.png (10.7 KB)
A simple Table HTML conversion to PDF format is not rendering Border styles correctly for the table.
using DocumentBuilder class -> InsertHTML method
Check attached pic to understand how table is wrongly getting converted

HTML code below:

<html><head></head><body style="font-family: &quot;Arial&quot;;font-size: 12pt;margin-left: 2.54cm !important;margin-right: 2.54cm !important;line-height: normal"><h2 style="font-family: &quot;Arial&quot;">testing</h2>
<p>Test McTest</p>
<table style="border-collapse: collapse; width: 100%; border-style: solid;" border="4">
<tbody>
<tr>
<td style="width: 19.3333%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
</tr>
<tr style="border-style: dashed;">
<td style="width: 19.3333%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
</tr>
<tr style="border-style: double;">
<td style="width: 19.3333%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%; border-style: outset;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
</tr>
<tr>
<td style="width: 19.3333%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%; border-style: hidden;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
<td style="width: 19.5%;">&nbsp;</td>
</tr>
</tbody>
</table></body></html>

@abhisheks9,

Even MS Word 2019 does not preserve formatting of Table borders when converting this HTML to PDF (msw-2019.pdf (10.0 KB)). For the sake of any corrections in Aspose.Words API, we have logged this problem in our issue tracking system. Your ticket number is WORDSNET-21751. We will further look into the details of this problem and will keep you updated on the status of linked issue.

1 Like