Free Support Forum - aspose.com

Aspose 20.12 html result question

we used 20.6 version of aspose. after upgrade to 20.12 we see another html.
For example
source html: <p style="margin-top:0pt; margin-bottom:0pt; font-size:12pt"> <span style="font-family:'Times New Roman'">Simple document with one paragraph and no additional formatting.</span> </p>

change html:
<p style="font-size:12pt; margin-bottom:0pt; margin-top:0pt"><span style="font-family:'Times New Roman'">Simple document with one paragraph and additional formatting.</span></p>

but result from compare now is :

  body style="font-family:'Times New Roman'; font-size:12pt">
		div>
			<p style="margin-top:0pt; margin-bottom:0pt">
				<span>Simple document with one paragraph and </span><del style="color:#b5082e; -aw-revision-author:'Parley Pro'; -aw-revision-datetime:'2020-12-29T19:35:36'"><span>no </span></del><span>additional formatting.</span>
			</p>
			<p style="margin-top:0pt; margin-bottom:0pt">
				<span style="-aw-import:ignore">&#xa0;</span>
			</p>
		div>
	body>

my code simple:

DocumentBuilder dbSource = new DocumentBuilder();
DocumentBuilder dbIncoming = new DocumentBuilder();
dbSource.insertHtml(source);
Document docSource = dbSource.getDocument();
dbIncoming.insertHtml(incoming);
Document docIncoming = dbIncoming.getDocument();
docSource.compare(docIncoming, “test”, new Date());
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.HTML);
htmlSaveOptions.setPrettyFormat(true);
htmlSaveOptions.setExportListLabels(ExportListLabels.AS_INLINE_TEXT);
htmlSaveOptions.setExportHeadersFootersMode(ExportHeadersFootersMode.NONE);
htmlSaveOptions.setExportImagesAsBase64(true);
htmlSaveOptions.setScaleImageToShapeSize(false);
htmlSaveOptions.setExportRoundtripInformation(true);
String result = docSource.toString(htmlSaveOptions);

So question why font and size moved to body? And can render html like before?
on version 20.6

<body>
	<div>
		<p style="margin-top:0pt; margin-bottom:0pt; font-size:12pt">
			<span style="font-family:'Times New Roman'">Simple document with one paragraph and </span><del style="color:#b5082e; -aw-revision-author:'Parley Pro'; -aw-revision-datetime:'2020-12-29T19:54:01'"><span style="font-family:'Times New Roman'">no </span></del><span style="font-family:'Times New Roman'">additional formatting.</span>
		</p>
		<p style="margin-top:0pt; margin-bottom:0pt; font-size:12pt">
			<span style="font-family:'Times New Roman'; -aw-import:ignore">&#xa0;</span>
		</p>
	</div>
</body>

@vhostt,

We have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-21603. 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.

@vhostt,

Regarding WORDSNET-21603, we have completed the work on this issue and concluded to close this issue with “not a bug” status. Starting from the 20.8 version, Aspose.Words writes default “font-size” and “font-family” values to <body> when saving a HTML document with inline CSS. Please try to 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>

If we can help you with anything else, please feel free to ask.