Free Support Forum - aspose.com

InsertHTML - random leading spaces

Using Aspose.Words 5.0, we are experiencing random leading spaces when using InsertHTML. I've attached the snippet of HTML that was inserted and the following reply will contain the resulting document.

The code that performs the insert is just 2 lines:

builder.InsertHtml(content);

builder.InsertHtml("
");

Attached is the resulting document. The inerted sample starts on page 9 and is labeled with the text

"Test Analysis: Behavior Assessment System for Children, Parent Rating Scales-Child"

Please let me know what you find...

Regards,

Binh

Hello Binh!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for asking this.

I tried to insert the given HTML fragment to an empty document and obtained some unexpected spaces as well. The code I was using is the following:

public static void TestRandomSpaces()

{

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

StreamReader reader = File.OpenText("random_spaces.txt");

string content = reader.ReadToEnd();

builder.InsertHtml(content);

builder.InsertHtml("
"
);

doc.Save("random_spaces_result.doc");

}

The issue has been logged as #4424 in our defect database. We’ll investigate it and provide more information when it is fixed or some update is available.

As a workaround you can try adding the contents by separate paragraphs.

Regards,

Great, I’m glad you were able to duplicate. Thanks for the quick response and great customer service!

Any estimates on when #4424 will be fixed?

Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

This issue is still open and I cannot give estimate. Have you tried adding text line by line? We can think about any other workarounds together.

Thank you for understanding,

I am welcome to any workarounds. However, I'm not sure what you mean by line by line. We have a WYSIWYG html editor that emits HTML fragments. These fragments are stored in the DB and read out into a InsertHTML call.

Could this issue be fixed by pre-processing the HTML somehow?

Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I meant that if your fragment consists of several sentences delimited by
you can try splitting it on them. Of course if fragments can be of any structure this is not a case.

I’ll come back to this issue but not immediately now.

Regards,

Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Issue #4424 is fixed in the current codebase. The next hotfix will be available most probably early next week.

Regards,

Any news on that hotfix?

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

This issue is already fixed as Viktor mentioned. We will publish the hotfix within week or two. Thanks for your patience.

Best regards.

Hello!<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

That’s even sooner. We planned to release on Monday but for technical reasons postponed this to one more day. I hope we release on Tuesday. Note possible difference in time zones.

Regards,

The issues you have found earlier (filed as 4424) have been fixed in this update.