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

Free Support Forum - aspose.com

Problem with InsertHtml

Hi,

Based on the code below, I was expecting the word document to have multiple spaces in "Line 1" (I have 5 spaces between "its words") and also two line breaks between Line 1 and Line 2.

However, all the extra spaces and break lines are being cleaned up.

Can you please let me know what the problem is?

Thanks

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

string line1 = "Line1 has a lot of text in it. This sentence has two spaces before 'The'. This sentence also has extra spaces within its words.";

string line2 = "Line2";

string line3 = "abcss def";

builder.InsertHtml(line1);

builder.InsertHtml("

");

builder.InsertHtml(line2);

builder.InsertHtml("
");

builder.InsertHtml(line3);

doc.Save(@"c:\test\document.docx");

Hello

Thanks for your request. I think in your case you should use   instead of white spaces:

"Line1 has a lot of text in it. This sentence has two spaces before 'The'. This sentence also has extra spaces within its     words."

Or you can try using builder.Writeln method instead of InsertHtml.

Hope this helps.

Best regards,

What about HTML break lines? Having multiple html break lines between Line1 and 2 still does not provide multiple breaks between the two lines. What would I need to do to implement multiple break lines..I've tried using InsertBreak(BreakType.LineBreak) and that doesn't solve the problem either.

Thanks.

Hello

Thanks for your inquiry. In this case you can try using Writeln or ParagraphBreak:

builder.Writeln();

builder.Writeln();

or

builder.InsertBreak(BreakType.ParagraphBreak);

Best regards,