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

Free Support Forum - aspose.com

Styling (CSS) not rendering when converting from HTML to .doc

Hello,
I am using Aspose.Words (Java) evaluation. The expected “Evaluation Only. Created with Aspose.Words. Copyright 2003-2008 Aspose Pty Ltd.” message displays at the top of the document. I have looked through the documentation and believe that the evaluation version supports the same as the purchased version (https://docs.aspose.com/words/net/licensing/).
My current issue is regarding styling. I need to open an HTML file and save it as a .doc. I see there are SaveOptions that can be set, and the default is CssStyleSheetType.INLINE for getHtmlExportCssStyleSheetType. However, I can’t control the HTML file and it has both embedded CSS and inline CSS. Is there an easy way to use both for proper rendering?
Additionally, if I set

doc.getSaveOptions().setHtmlExportCssStyleSheetType(CssStyleSheetType.EMBEDDED); 

the document still only displays what seems to be the default:
Size 12 font
Times New Roman
Left justified
The tag does not render properly either. Even though is deprecated it still exists in some of our old documents. The only styling that seems to work are elements with the following attribute: align=“center” and various HTML tags such as , (also deprecated but still works), etc.
My code is rather simple:

Document doc = new Document("exportStyleTesting.html");
doc.getSaveOptions().setHtmlExportCssStyleSheetType(CssStyleSheetType.EMBEDDED); /* would want both inline and embedded */
doc.save("exportStyleTesting.doc");

Is there something I am missing as to why my document is all Times New Roman size 12 font and not rendering properly even though there is inline and embedded CSS in “exportStyleTesting.html?”
Regards.

Hi

Thanks for your inquiry. SaveOptions does not matter when you open the document. SaveOptions does matter only when you save the document.
Please attach your HTML document for testing. We will investigate the issues and provide you more information.
Also, if you would like to test Aspose.Words without the evaluation version limitations, you can request a 30-day Temporary License. Please refer to
https://purchase.aspose.com/temporary-license
Best regards.

Thanks for your response. I have attached the HTML file along with two documents for comparison.

Regards.

Hi

Thank you for additional information.

  1. tags are currently not supported. This is the issue #5894 in our defect database. As a workaround, you can try specifying on paragraph instead of using tags.
  2. Inheriting of styles is not supported. This is issue #7234 in our defect database.
  3. CSS styles are not fully supported during HTML import. This is issue #40 in our defect database. As a workaround you can use inline styles.

Also, see the following document to learn more about restriction of HTML import/export:
https://releases.aspose.com/words/net
Best regards.

Thanks for your quick response. I greatly appreciate it.

I don’t believe you have a public defect tracking system so would be able to give any insight on the defects listed above? Are these defects in an active pool or have most of them been shelved?

Regards, and thanks again.

Hi

Thanks for your request. All issues are in active pool; however, I cannot promise you that all issues will be resolved in the nearest future, since the issues should be first fixed on .NET baseline and then ported to Java. Only porting process can take month or two.
Best regards.

The issues you have found earlier (filed as 5894) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as WORDSNET-39) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(56)

The issues you have found earlier (filed as WORDSNET-2021) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(33)