Superscript font size changes when converting docx to html

Hello,

Please find attached document. The superscript for “2nd”, is actually font size 12. However, when converted to HTML it is getting converted to 8. Which creates an issue when converting back to docx as the size keeps reducing.
Test-SoftLineBreaks2.docx (9.7 KB)

I had seen some previous discussions around this in the forum and not sure if this is still an open issue or there is some alternative approach or workaround to resolve this behavior.

Thanks for any assistance!

@kml2020 As I can see font size is properly roundtripped after DOCX-HTML-DOCX conversion. I have used the following code for testing:

Document doc = new Document("C:\\Temp\\in.docx");
    
HtmlSaveOptions opt = new HtmlSaveOptions();
opt.setPrettyFormat(true);
    
// Save as HTML
doc.save("C:\\Temp\\out.html", opt);
    
// Open document from HTML
Document doc1 = new Document("C:\\Temp\\out.html");
doc1.save("C:\\Temp\\out.docx");

Though superscripted text font in the output HTML is 8pt, in the roundtripped DOCX document it is still 12pt as expected.

Hello @alexey.noskov,

Is there some ratio or formula, where this translation from 12pt to 8 pt happens. I guess, trying to understand this change in size. We also store the font size on the round trip back and in this case our font size is getting stored as 8pt. How does Aspose know to turn 8pt into 12pt for superscripts ?

@kml2020 In MS Word, text with Font.Subscript or Font.Superscript property set is rendered in 2/3 of its specified size. To compensate the font size reduction we increase the font size specified in HTML by 3/2 = 1.5.

Awesome. This is helpful. Thank you, @alexey.noskov

1 Like