Formatting of Inserted Html

Why has the inserted HTML text its paragraph format as "Normal, After 14pt " ?
It is impossible to have it without any “After” space…
I tried with the following code :
>>>
sHTMLValue = “

Simple paragraphe 1

Simple paragraphe 2

Simple paragraphe 3


+ “<p style=“LINE-HEIGHT: Normal”>Simple paragraphe 1 (Normal)

<p style=“LINE-HEIGHT: Normal”>Simple paragraphe 2 (Normal)<p style=“LINE-HEIGHT: Normal”>Simple paragraphe 3 (Normal)”
+ “<p style=“LINE-HEIGHT: 14px”>Simple paragraphe 1 (14px)<p style=“LINE-HEIGHT: 14px”>Simple paragraphe 2 (14px)<p style=“LINE-HEIGHT: 14px”>Simple paragraphe 3 (14px)”
;

DocumentBuilder oBuilder = new DocumentBuilder(e.Document);
oBuilder.InsertHtml(sHTMLValue);
>>>

What do I have to do to get rid of this “After” space ?

Hi,

You might have noticed that MS Word inserts "Auto" spacing after HTML paragraphs which is almost equivalent to 14 pt spacing. We try to make Aspose.Words behaviour similar to Word. If you need to get rid of spacing after paragraphs, run the following code after importing from HTML:

NodeList paragraphs = doc.SelectNodes("//Paragraph");

foreach (Paragraph paragraph in paragraphs)

{

paragraph.ParagraphFormat.SpaceAfterAuto = false;

paragraph.ParagraphFormat.SpaceAfter = 0;

}

Thanks a lot for your quick answer !

But, is there any way to identify the paragraph that we inserted using InsertHTML ?
Because some of my paragraphs (the ones not produced with InsertHTML) need to have their own spacing…

I did the identification adding the test : ([…].SpaceAfterAuto && ([…].SpaceAfter == 14))… It works but it is not a safe way.

I’m afraid other ways to determine if a particular paragraph has been imported from HTML are more complicated. For example, you can put some marks before and after each HTML insertion, say special text or bookmarks or something. When enumerating the retrieved paragraphs, you should then turn on and off the correction of the spacing depending on whether the paragraph is located between the marks. You should also delete the marks eventually… This looks complex for such the task so you should choose between safety and complexity.