Good morning! We use Aspose HTML 20.9.0 to convert client HTML documents to PDF. Product works great except in one instance where we have a table with percentage width columns and colspans. The first row doesn’t contain any content and just specifies column widths that total up to 100%: 1%, 50%, etc.
The second row’s first column has a colspan of 2 and it enlarges the width of the first column dramatically even though there is plenty of room in the second one. Opening the HTML in any browser produces the expected output. Here is the simplified HTML with coloring to identify columns:
<table cellpadding="0" cellspacing="0" width="100%">
<tr style="font-size:1pt;">
<td style="width:1%; background-color:yellow; height:20px;"> </td>
<td style="width:50%; background-color:orange;"> </td>
<td style="width:15%; background-color:yellow;"> </td>
<td style="width:1%; background-color:orange;"> </td>
<td style="width:10%; background-color:yellow;"> </td>
<td style="width:1%; background-color:orange;"> </td>
<td style="width:10%; background-color:yellow;"> </td>
<td style="width:1%; background-color:orange;"> </td>
<td style="width:10%; background-color:yellow;"> </td>
<td style="width:1%; background-color:orange;"> </td>
</tr>
<tr>
<td colspan="2" style="background-color:yellow;">
<p>Management fees</p>
</td>
</tr>
<tr>
<td>
<p style="background-color:yellow;">1</p>
</td>
<td colspan="9" style="background-color:orange;">
<p>
Estimates are for the current
fiscal year.
</p>
</td>
</tr>
</table>
And here is the code:
static void Main(string[] args)
{
// Initialize the PDF options
PdfSaveOptions options = new PdfSaveOptions();
options.PageSetup.AnyPage.Margin.Bottom = options.PageSetup.AnyPage.Margin.Top = options.PageSetup
.AnyPage.Margin.Left = options.PageSetup.AnyPage.Margin.Right = Length.FromInches(0.3);
options.PageSetup.AnyPage.Size.Height
= Length.FromInches(14);
options.PageSetup.AnyPage.Size.Width
= Length.FromInches(8.5);
options.JpegQuality = 100;
// Load the Aspose.HTML License and input document
new License().SetLicense(...);
String content = File.ReadAllText(Environment.CurrentDirectory + "\\Input.htm");
HTMLDocument htmlDocument = new HTMLDocument(content, "");
// Convert and open the converted document
String outputFile = Environment.CurrentDirectory + "\\Output.pdf";
Converter.ConvertHTML(htmlDocument, options, outputFile);
Process.Start("cmd", String.Format(
"/c start \"\" \"{0}\"",
outputFile));
}
Conversion works fine with pixel widths:
<td style="width:8px; background-color:yellow; height:20px;"> </td>
<td style="width:421px; background-color:orange;"> </td>
<td style="width:126px; background-color:yellow;"> </td>
<td style="width:8px; background-color:orange;"> </td>
<td style="width:83px; background-color:yellow;"> </td>
<td style="width:8px; background-color:orange;"> </td>
<td style="width:83px; background-color:yellow;"> </td>
<td style="width:8px; background-color:orange;"> </td>
<td style="width:83px; background-color:yellow;"> </td>
<td style="width:8px; background-color:orange;"> </td>
I attached the output:
image.png (6.8 KB)
Thanks!