InsertHTML Method is ruining ParagraphFormat for the entire document

I have a simple test setup in which I add some HTML to a document & then try to format the paragraph after the InsertHTML method is called.

What I am trying to do is have the Writeln method called after InsertHTML have 0 spacing before & after the text. Currently, the Writeln writes the text with “auto” spacing after (ParagraphFormat.SpaceAfter is incorrectly set to Auto instead of “0”, even though it is explicitly called).

Here is the code:

public Document createTestReport()
{
	Document doc = new Document();
	DocumentBuilder db = new DocumentBuilder(doc);
 
    db.InsertParagraph();
    db.ParagraphFormat.SpaceAfter = 0;
    db.ParagraphFormat.SpaceBefore = 0;
 
	db.InsertHtml("<p>BlahBlahBlah</p><ul><li>Some List Item</li><li>Another</li></ul>");
 
	db.Font.Bold = true;
    db.ParagraphFormat.SpaceAfter = 0;
    db.ParagraphFormat.SpaceBefore = 0;
	db.Writeln("Some Title");
 
	return doc;
}

Hi Dan,
Thanks for your inquiry. Please note that, content inserted by DocumentBuilder.insertHtml method does not inherit formatting specified in DocumentBuilder options. Whole formatting is taken from HTML snippet. If you insert HTML with no formatting specified, then default formatting is used for inserted content.
Please call ParagraphFormat.ClearFormatting method after inserting the HTML. This method resets to default paragraph formatting.

Document doc = new Document();
DocumentBuilder db = new DocumentBuilder(doc);

db.InsertParagraph();
db.ParagraphFormat.SpaceAfter = 0;
db.ParagraphFormat.SpaceBefore = 0;

db.InsertHtml("<p>BlahBlahBlah</p><ul><li>Some List Item</li><li>Another</li></ul>");

db.ParagraphFormat.ClearFormatting();
db.Font.Bold = true;
db.ParagraphFormat.SpaceAfter = 0;
db.ParagraphFormat.SpaceBefore = 0;
db.Writeln("Some Title");