Free Support Forum - aspose.com

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 “border-spacing: 0.7pt;”. It leads to the “width: 375pt;” 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 “toto: 0.7pt;”.

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;”> <table style=“width: 375pt; border-spacing: 0.7pt;” cellspacing=“1” cellpadding=“0”> <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;”>BETWEEN:<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 Name<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;”>  <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;”> <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 style=“font-family: Arial;”>Vancouver, BC
<span style=“font-family: Arial; background-color: #ffff00;”>Tenant Postal Code

<span style=“font-family: Arial;”>(as “Tenant”) ";
saveToPdf(bug, “bug”);

final String bug2 = “<p style=“margin: 0px 0px 0px 0px; padding-left: 0pt; text-align: center;”> <table style=“width: 375pt; toto: 0.7pt;” cellspacing=“1” cellpadding=“0”> <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;”>BETWEEN:<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 Name<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;”>  <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;”> <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 style=“font-family: Arial;”>Vancouver, BC
<span style=“font-family: Arial; background-color: #ffff00;”>Tenant Postal Code

<span style=“font-family: Arial;”>(as “Tenant”) ";
saveToPdf(bug2, “bug2”);

final String good = “<p style=“margin: 0px 0px 0px 0px; padding-left: 0pt; text-align: center;”> <table style=“width: 375pt;” cellspacing=“0.7pt” cellpadding=“0”> <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;”>BETWEEN:<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 Name<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;”>  <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;”> <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 style=“font-family: Arial;”>Vancouver, BC
<span style=“font-family: Arial; background-color: #ffff00;”>Tenant Postal Code

<span style=“font-family: Arial;”>(as “Tenant”) ";
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.