Aspose Word formatting issue when converting HTML to Word

The problem is in the way that Aspose.Words interprets a specific formatting in the html that it uses to render the Word doc.

{Name}
{AddressBlock} 

Mary Jones
Director of Development

Example of resulting text.

Joe Smith
1234 Main Street
New York, NY 90026

Mary Jones
Director of Development

In both of these cases, when there is a line of text followed by an html line break, then a literal new line and another line of text. Aspose.Word injects a space before the second line of text. The workaround is to put the line break after the first line of text on its own line.

{Name}
{AddressBlock} 

Mary Jones
Director of Development

This removes the space that Aspose.Word injects before the second line of text.

We are contemplating a programmatic solution, but we’re hoping this is a bug that can be fixed in Aspose.Word.

Thanks,
Scott Slaten

Hi

Thanks for your request. I tried to use the following HTML for testing and it seems that all works fine on my side.

<html>
<body>
Joe Smith<br />
1234 Main Street New York, NY 90026  <br />
Mary Jones<br />
Director of Development
</body>
</html>

After converting I got the following text.


Joe Smith
1234 Main Street New York, NY 90026
Mary Jones
Director of Development


Here is my code.

Document doc = new Document(@"Test097\in.html");
doc.Save(@"Test097\out.doc");

Maybe there is something wrong with your HTML. Could you please provide me your HTML document and code that will allow me to reproduce the issue?

Best regards.

Hi Alexey,

Which version of Aspose.Word are you using? I appear to be getting the same results. Although I’m going to try a couple more tests.

Thanks,
Scott Slaten

I’ve upgraded to the latest version, 5.1.0. It looks like the problem is fixed in this release.

Thanks,
Scott

Hello Scott!

This issue was really fixed in Aspose.Words 5.1.0:

There are two lists below the download file details: What’s new and Fixes. Here you can see our update relative to the previous version.

This is the issue considered in this thread:
#4424 | Model | Unexpected spaces appear after InsertHtml call.

Best regards,

Dear Sir/Madam,

Mail Merge fails when using MS Word AddressBlock. Do you have support for this feature or not?

Expected reply soon.

Regards,

Sujitha

Hi

Thanks for your inquiry. Could you please provide me your code and attach the template document for testing?

Best regards.