We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Removal of white spaces using inserthtml

Hi - aspose.inserthtml(“hello there”) removes white spaces between words. Is there a way to get around this?

Hi
Thanks for your inquiry. By design several white spaces are replaced by one white space. If you need several white spaces in the html string then you can use the following code.

builder.InsertHtml("hello  there");

Also you can try using

builder.Write("hello there");

Best regards.

I tested your code and it does not remove white space. It collapses whitespace according to HTML whitespace handling rules. In your case one space between words remains one space between words.

[Test]
public void TestHelloThere()
{
    mBuilder.InsertHtml("hello there");
    Assert.AreEqual("hello there\x000c", mDoc.GetText());
}

If you want more spaces between words then you can use or like this(two spaces between words):

[Test]
public void TestHelloThere()
{
    mBuilder.InsertHtml("hello  there");
    
    Assert.AreEqual("hello  there\x000c", mDoc.GetText());
}

So it all works fine.