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

Free Support Forum - aspose.com

Html export problem

Hello,

When I save Aspose.Words generated documents in html, some tables are not rendered correctly.
Please find attached the generated Word documents and their html versions.
Do you any solution to fix this?

Thank you.

Regards.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Hello!

Thank you for your inquiry. Some issues with tables show up. I’ll investigate these cases and reply in a few days.

Regards,

Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your patience.

In 2008-07-10_16h36m51s_79_520_A4511CFF15B57A59.doc there are two extra padding columns in the first row. They are not visible in MS Word but some additional cells are reserved. That’s why we get colspan=”<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />3” instead of “2”. To help with this document I would like first ask how you get it. MS Word usually doesn’t save documents with such padding cells. As a workaround you can try re-creating the first row entirely.

In 2008-07-21_20h49m26s_45_5800_FSOCIETESAGSL37658.doc I see that some column widths are rendered differently despite of equal td width="XXX" attributes in the cells. Maybe that’s also related to how the document was created.

Any additional information would be much appreciated. Thank you.

Regards,

Hello,

Thank you for your answer. The documents were created from a word template document containing all the styles needed (paragraph, character and list). The content of the document is created from a XML using the DocumentBuilder functions.

Regarding the first document, here is the code that reproduces the problem :

public static void Doc1()
{
double[] widths = {
1.327172305416898, 2.4950839341837683, 1.3537157515252363, 2.7074315030504725,
1.8049543353669817, 1.5395198742836018, 1.5926067665002777, 1.5660633203919399,
1.5660633203919399
};
for (int i = 0; i < 9; i++)
{
widths[i] = ConvertUtil.MillimeterToPoint(widths[i] * 10);
//widths[i] = Math.Round(ConvertUtil.MillimeterToPoint(widths[i] * 10), 2);
}
LoadAsposeLicense();
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
SetTableFormat(builder);
builder.StartTable();
Cell cell = builder.InsertCell();
cell.CellFormat.Width = (widths[0] + widths[1]);
builder.Write(“Date limite”);
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[2] + widths[3] + widths[4]);
builder.Write(“Opérations nécessaires”);
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[5] + widths[6]);
builder.Write(“Avec documents de gestion prévisionnelle”);
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[7] + widths[8]);
builder.Write(“Sans documents de gestion prévisionnelle”);
builder.EndRow();
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[0] + widths[1]);
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[2] + widths[3] + widths[4]);
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[5]);
builder.Write(“Avec Commissaire aux comptes”);
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[6]);
builder.Write(“Sans Commissaire aux comptes”);
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[7]);
builder.Write(“Avec Commissaire aux comptes”);
cell = builder.InsertCell();
cell.CellFormat.Width = (widths[8]);
builder.Write(“Sans Commissaire aux comptes”);
builder.EndRow();
builder.EndTable();
doc.Save(@“D:\Dev\Osi_Xhtml2Word\Data\Test\doc1.doc”, SaveFormat.Doc);
doc.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.Embedded;
doc.SaveOptions.HtmlExportXhtmlTransitional = true;
doc.Save(@“D:\Dev\Osi_Xhtml2Word\Data\Test\doc1.html”, SaveFormat.Html);
}

The second document was created the same way.

Hope this helps.

Regards


Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Here we tried the same but with rounding to _one_ decimal fractional digit:

widths[i] = Math.Round(ConvertUtil.MillimeterToPoint(widths[i] * 10), 1);

This works fine. The reason is probably that MS Word rounds such values itself without any external control. Aspose.Words deals with widths as they are, without implicit rounding. I think this shouldn’t be considered as defect since you can control rounding programmatically.

Please check this on you side and let us know whether our approach works for you.

Regards,

Hello,

This works.

Thank you very much.

Regards,