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

Free Support Forum - aspose.com

InsertHTML with table html and formatting for border-collapse is rendering wrong

If I insert html via the code below the header row has a white line that renders through it:

var doc = new Document();
var builder = new DocumentBuilder(doc);

builder.InsertHtml(
@"
	<style>
		table.foo {
			border-collapse: collapse;
		}
		table.foo thead tr th {
			background-color: #999;
			font-weight: bold;
			padding: 2px;
			border: 1px solid black;
		}
		table.foo thead tr th.col1 {
			width: 100px;
		}
		table.foo thead tr th.col2 {
			width: 200px;
		}
		table.foo tbody tr td {
			padding: 2px;
			border: 1px solid black;
		}
	</style>
	<p>First paragraph</p>
	<table class='foo'>
		<thead>
			<tr>
				<th class='col1'>Text</th>
				<th class='col2'>Value</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td>Name</td>
				<td>Terry</td>
			</tr>
			<tr>
				<td>DOB</td>
				<td>5/9/1973</td>
			</tr>
		</tbody>
	</table>
");

doc.Save(@"c:\btr\temp\" + "DocumentBuilder.InsertHtmlWithFormatting.docx");

DocumentBuilder.InsertHtmlWithFormatting.docx (6.0 KB)

Any suggestions on how to remove it?

@terry.aney,
Unfortunately, we were unable to reproduce the same issue on our side. I can’t see an unwanted white line in the header row of a rendered table in your output document. Could you please share a screenshot, that shows the unexpected behavior? We will investigate the issue and provide you information on it.

Screenshot 2021-12-13 181349.png (40.9 KB)
When I changed the zooming, the white line would disappear at some levels, but at 100% zoom, you can see it.

@terry.aney This is not Aspose.Words issue. This is some kind of MS Word glitch. I have created a simple table in MS Word with similar options as in the table generated from your HTML by Aspose.Words and I can observe the same ghost white line on some zoom levels.
ms.docx (12.5 KB)
image.png (1.7 KB)