Word to HTML Conversion using Aspose.Words for Java | Body Tag Inline CSS Styles | Font Formatting <p> <span> <div> Tags

Hi there,

We are upgrading Aspose in our product and noticed a breaking change.

In 16.4.0, the font information for a paragraph is converted to <p> and <span> inline CSS.

<body>
  <div>
    <p style="margin-top:0pt; margin-left:28.8pt; margin-bottom:0pt; **font-size:12pt**">
      <span **style="font-family:'Times New Roman'"**>Simple indented paragraph</span>
    </p>
  </div>
</body>

But in 20.11, the inline styles are moved to <body> tag

<body **style="font-family:'Times New Roman'; font-size:12pt"**>
  <div>
    <p style="margin-top:0pt; margin-left:28.8pt; margin-bottom:0pt"> 
      <span>Simple indented paragraph</span>
    </p>
  </div>
</body>

Our site displays the converted content inside <body> tag as a partial of the page, which means the CSS attached to body tag is gone. Is there a workaround to make the conversion work as before? Many thanks.

Best regards,
Zac

body inline css support.zip (2.8 KB)

@zac1st1k,

We have logged this problem in our issue tracking system with ID WORDSNET-21479. We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for your inconvenience.

@zac1st1k,

I see that you post-process the HTML document generated by Aspose.Words. As a workaround, could you change the <body> and </body> tags to <div> and </div> respectively during post-processing? For example, see the following code:

<body style="font-family:'Times New Roman'; font-size:12pt">
  <div>
    <p style="margin-top:0pt; margin-left:28.8pt; margin-bottom:0pt"> 
      <span>Simple indented paragraph</span>
    </p>
  </div>
</body>

and replace body tags:

<div style="font-family:'Times New Roman'; font-size:12pt">
  <div>
    <p style="margin-top:0pt; margin-left:28.8pt; margin-bottom:0pt"> 
      <span>Simple indented paragraph</span>
    </p>
  </div>
</div>