Html to PDF conversion : Table rendering

Hello,
In my process, I convert some html to .doc & .pdf using Aspose.Words.
I have an issue when converting some table with style "<span style="font-size: small;">border-spacing: 0.7pt;</span>". It leads to the "<span style="font-size: small;">width: 375pt;</span>" style to be ignored, producing a bad pdf in the end.

Here is some code to reproduce the issue (producing the attached pdfs)
“String bug” is a html that reproduce the issue.
“String good” is a html that lead to a correct pdf.
“String bug2” is another html that reproduce the issue with style "<span style="font-size: small;">toto: 0.7pt;</span>".

public static void main(final String... args) throws Exception
{
    final String bug = "<p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt; text-align: center;\">&nbsp;</p><table style=\"width: 375pt; border-spacing: 0.7pt;\" cellspacing=\"1\" cellpadding=\"0\"><tbody><tr><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-family: Arial; font-size: 11pt;\"><strong>BETWEEN:</strong></span></p></td><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-size: 11pt;\"><span style=\"font-family: Arial; background-color: #ffff00;\"><strong>Tenant Name</strong></span><img style=\"-aw-left-pos: 0pt; -aw-rel-hpos: column; -aw-rel-vpos: paragraph; -aw-top-pos: 0pt; -aw-wrap-type: inline;\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAEUlEQVR4nGNgGAWjYBQMIgAAA5MAAZrvkucAAAAASUVORK5CYII =\" alt=\"data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw = =\" width=\"15\" height=\"15\"><span style=\"font-family: Arial;\"><strong>&nbsp;</strong></span></span></p></td></tr><tr><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-family: Arial; font-size: 11pt;\">&nbsp;</span></p></td><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-size: 11pt;\"><span style=\"font-family: Arial; background-color: #ffff00;\">Tenant Address</span><br><span style=\"font-family: Arial;\">Vancouver, BC</span><br><span style=\"font-family: Arial; background-color: #ffff00;\">Tenant Postal Code</span><br><br><span style=\"font-family: Arial;\">(as \"Tenant\")</span></span></p></td></tr></tbody></table>";
    saveToPdf(bug, "bug");

    final String bug2 = "<p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt; text-align: center;\">&nbsp;</p><table style=\"width: 375pt; toto: 0.7pt;\" cellspacing=\"1\" cellpadding=\"0\"><tbody><tr><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-family: Arial; font-size: 11pt;\"><strong>BETWEEN:</strong></span></p></td><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-size: 11pt;\"><span style=\"font-family: Arial; background-color: #ffff00;\"><strong>Tenant Name</strong></span><img style=\"-aw-left-pos: 0pt; -aw-rel-hpos: column; -aw-rel-vpos: paragraph; -aw-top-pos: 0pt; -aw-wrap-type: inline;\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAEUlEQVR4nGNgGAWjYBQMIgAAA5MAAZrvkucAAAAASUVORK5CYII =\" alt=\"data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw = =\" width=\"15\" height=\"15\"><span style=\"font-family: Arial;\"><strong>&nbsp;</strong></span></span></p></td></tr><tr><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-family: Arial; font-size: 11pt;\">&nbsp;</span></p></td><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-size: 11pt;\"><span style=\"font-family: Arial; background-color: #ffff00;\">Tenant Address</span><br><span style=\"font-family: Arial;\">Vancouver, BC</span><br><span style=\"font-family: Arial; background-color: #ffff00;\">Tenant Postal Code</span><br><br><span style=\"font-family: Arial;\">(as \"Tenant\")</span></span></p></td></tr></tbody></table>";
    saveToPdf(bug2, "bug2");

    final String good = "<p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt; text-align: center;\">&nbsp;</p><table style=\"width: 375pt;\" cellspacing=\"0.7pt\" cellpadding=\"0\"><tbody><tr><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-family: Arial; font-size: 11pt;\"><strong>BETWEEN:</strong></span></p></td><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-size: 11pt;\"><span style=\"font-family: Arial; background-color: #ffff00;\"><strong>Tenant Name</strong></span><img style=\"-aw-left-pos: 0pt; -aw-rel-hpos: column; -aw-rel-vpos: paragraph; -aw-top-pos: 0pt; -aw-wrap-type: inline;\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAEUlEQVR4nGNgGAWjYBQMIgAAA5MAAZrvkucAAAAASUVORK5CYII =\" alt=\"data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw = =\" width=\"15\" height=\"15\"><span style=\"font-family: Arial;\"><strong>&nbsp;</strong></span></span></p></td></tr><tr><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-family: Arial; font-size: 11pt;\">&nbsp;</span></p></td><td style=\"padding: 0.75pt; vertical-align: middle;\"><p style=\"margin: 0px 0px 0px 0px; padding-left: 0pt;\"><span style=\"font-size: 11pt;\"><span style=\"font-family: Arial; background-color: #ffff00;\">Tenant Address</span><br><span style=\"font-family: Arial;\">Vancouver, BC</span><br><span style=\"font-family: Arial; background-color: #ffff00;\">Tenant Postal Code</span><br><br><span style=\"font-family: Arial;\">(as \"Tenant\")</span></span></p></td></tr></tbody></table>";
    saveToPdf(good, "good");
}

private static void saveToPdf(final String html, final String out) throws Exception
{
    final com.aspose.words.Document document = new com.aspose.words.Document();
    final DocumentBuilder builder = new DocumentBuilder(document);
    builder.insertHtml(html);

    final DocSaveOptions soDoc = new DocSaveOptions();
    soDoc.setUseAntiAliasing(true);
    soDoc.setUseHighQualityRendering(true);
    document.save(out +".doc", soDoc);

    final PdfSaveOptions soPdf = new PdfSaveOptions();
    soPdf.setTextCompression(PdfTextCompression.NONE);
    soPdf.setUseHighQualityRendering(true);
    soPdf.setUseAntiAliasing(true);
    soPdf.setEmbedFullFonts(false);

    document.save(out +".pdf", soPdf);
}

A very strange thing in this code is that if I remove the “save to doc” part (which seems useless), then the “String good” leads to a bad pdf too…

Can you help me on this ?

Hi Paulin,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-14560. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi,


Any news regarding this issue ?
Hi Paulin,

Thanks for your inquiry. We regret to share with you that your issue (WORDSNET-14560) has been postponed due to following missing features which are related to your issue.

WORDSNET-4794 : Cell spacing/ ROOT Support cell spacing in layout
WORDSNET-832 : Make table layout as close to Word as possible

After the fix of these features, our product team will look into your issue. We will be sure to inform you via this forum thread as soon as this feature is available.

We apologize for your inconvenience.

Hi,


Any chance you had some progress on this ?
Hi Paulin,

Thanks for your inquiry. Unfortunately, you issue is still postponed due to missing features (WORDSNET-4794 and WORDSNET-832). We will inform you via this forum thread as soon as there are any further developments

We are really very sorry for your inconvenience.

The issues you have found earlier (filed as WORDSNET-14560) have been fixed in this Aspose.Words for .NET 23.7 update also available on NuGet.