Default property value line-height is not explicitely set when converting from docx to html

I have converted a word document to html, the word document contains paragraphs with different line spacing values, among them one paragraph that does not define an explicit spacing (no w:spacing in the openxml file or the default one).
When converting this file to html, all paragraphs with spacing value different than the default value will generate a line-height property, while the ones with no explicit value or default value does not generate the property line-height (so it will inherits it from its ancestors or will depends on the browser if it was never defined).
Is there a way to force Aspose to generate default values for line-height even if it was not explicitly defined in the docx file ?
My docx (4.1 KB)

Code to convert from DOCX to HTML:

        // Load the document.
        Document doc = new Document(dataDir + String.format(INPUT, name));

        HtmlSaveOptions options = new HtmlSaveOptions(); + String.format(HTML, name), options);

        //Save the document Docx file format
        System.out.println("Document converted to html successfully.");


Please note that Aspose.Words mimics the behavior of MS Word. If you convert your document to HTML using MS Word, you will get the same output.

Could you please share some more detail about your requirement along with expected output HTML? We will then provide you more information on it.

We have a contract lifecycle management product which allow users to create/edit contracts (among other features).

We have two ways of creating contract (in fact three ways, but the third one is not interesting in this context) :

  • Importing it from a word document (using aspose for DOCX -> HTML conversion)
  • Create it in our internal editor

For the second way we define a default value for line-height equal to 140%

For the first way, we want to keep html rendering as close as possible to the original word document: so for single line spacing in word, we want a line-height of 100% in HTML.

In the provided document, I have created three paragraphs: the first one with a line spacing of 1 (100%), the second one with a line spacing of 1.15 (115%) and the third with 1.5 (150%). When converted to html, Aspose generates only line-height for the second (line-heigth=115%) and the third (line-height=150%)
For the first one, it won’t generate this property (while we are expecting it to generate a value of 100%)

if we embed the generated html into another html (what we do in our case to embed the html inside our editor), if not defined, the line-height will be inherited from default value defined in our platform which is 140%

So once this doc is imported to our platform, we will end up by: First paragraph (computed line-height=140%), second (line-height=115%), third (line-height=150%)

As you could notice here: in the original word the line spacing of the second paragraph is larger than the line spacing of the first paragraph, while in our platform it is the opposite.
If line-height was defined for the first paragraph we won’t have this problem.

Hope I was clear this time :slight_smile:


We have logged this problem in our issue tracking system as WORDSNET-21227 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-21227) as ‘Not a Bug’.

Please note that Aspose.Words never writes default values for CSS properties and it is unlikely will be changed. You should isolate html that insert into other html using container and/or CSS styles or you need to insert “line-height: 100%” after export.