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

Free Support Forum - aspose.com

Preserve Spacing during Converting Base64 Encoded HTML Table To Word DOCX using C#

Hello,
I have created html and adding intentional white space/newlines in the table cell. Aspose is getting rid of the space or new lines. Here is the sample Base64encoded html.
PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgVHJhbnNpdGlvbmFsLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXRyYW5zaXRpb25hbC5kdGQiPjxodG1sIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hodG1sIiB4bWw6bGFuZz0iZW4iIGxhbmc9ImVuIj48aGVhZD48dGl0bGU+QXV0b21hdGljYWx5IGdlbmVyYXRlZCBkb2N1bWVudDwvdGl0bGU+PHN0eWxlPnAsIGxpLCBkaXYKewptYXJnaW4tdG9wOjYuMHB0OwptYXJnaW4tcmlnaHQ6MGluOwptYXJnaW4tYm90dG9tOjYuMHB0OwptYXJnaW4tbGVmdDowaW47CnBhZGRpbmctbGVmdDowaW47CnRleHQtYWxpZ246anVzdGlmeTsKZm9udC1zaXplOjEwLjBwdDsKZm9udC1mYW1pbHk6IkFyaWFsIixzYW5zLXNlcmlmOwpjb2xvcjpibGFjazsKfQpoMQp7Cm1hcmdpbi10b3A6MjQuMHB0OwptYXJnaW4tcmlnaHQ6MGluOwptYXJnaW4tYm90dG9tOjYuMHB0OwptYXJnaW4tbGVmdDowaW47CmJvcmRlcjogMDsKYm9yZGVyLWJvdHRvbTogc29saWQgIzAwMDAwMCAxLjVwdDsKcGFkZGluZzowaW47CmZvbnQtc2l6ZToyNC4wcHQ7CmZvbnQtZmFtaWx5OiJBcmlhbCIsc2Fucy1zZXJpZjsKY29sb3I6YmxhY2s7Cn0KaDIKewptYXJnaW4tdG9wOi4yNWluOwptYXJnaW4tcmlnaHQ6MGluOwptYXJnaW4tYm90dG9tOjYuMHB0OwptYXJnaW4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AgICA8dGQgc3R5bGU9IndpZHRoOiAyNSU7Ij5Db2x1bW4zPC90ZD4gCiAgICAgPHRkIHN0eWxlPSJ3aWR0aDogMjUlOyI+Q29sdW1uNDwvdGQ+IAogICAgPC90cj4gCiAgIDwvdGhlYWQ+IAogICA8dGJvZHk+IAogICAgPHRyPiAKICAgICA8dGQgc3R5bGU9IndpZHRoOiAyNSU7Ij5WYWx1ZTExIAogCiA8L3RkPiAKICAgICA8dGQgc3R5bGU9IndpZHRoOiAyNSU7Ij5WYWx1ZTEyPC90ZD4gCiAgICAgPHRkIHN0eWxlPSJ3aWR0aDogMjUlOyI+VmFsdWUxMzwvdGQ+IAogICAgIDx0ZCBzdHlsZT0id2lkdGg6IDI1JTsiPlZhbHVlMTQ8L3RkPiAKICAgIDwvdHI+IAogICAgPHRyPiAKICAgICA8dGQgc3R5bGU9IndpZHRoOiAyNSU7Ij4gPHA+VmFsdWUyMTwvcD4gPHA+PC9wPiA8L3RkPiAKICAgICA8dGQgc3R5bGU9IndpZHRoOiAyNSU7Ij5WYWx1ZTIyPC90ZD4gCiAgICAgPHRkIHN0eWxlPSJ3aWR0aDogMjUlOyI+VmFsdWUyMzwvdGQ+IAogICAgIDx0ZCBzdHlsZT0id2lkdGg6IDI1JTsiPlZhbHVlMjQ8L3RkPiAKICAgIDwvdHI+IAogICA8L3Rib2R5PiAKICA8L3RhYmxlPiAKIDwvZGl2PiAgCjwvYm9keT48L2h0bWw+

@ShivaShanker,

Thanks for your inquiry. It would be great if you please ZIP and upload your simplified input HTML file and Aspose.Words generated output Word DOCX document showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.

Test.zip (25.7 KB)

Please find the attached word doc and html pages. I have added Actual and Expected Behaviour as well.

@ShivaShanker,

I am afraid, even MS Word 2019 does not preserve that empty line in generated DOCX file. Please see the following HTML and Word documents:

  • HTMLPage1.zip (948 Bytes) - Input HTML File
  • msw-2019.zip (10.5 KB) - Produced by using Save As command of MS Word 2019
  • 20.4.zip (5.4 KB) - Produced by using the following code:

C# Code:

string base64Encoded = "put your base64 Encoded HTML string here";
byte[] data = System.Convert.FromBase64String(base64Encoded);
MemoryStream stream = new MemoryStream(data);
stream.Position = 0;
HtmlLoadOptions opts = new HtmlLoadOptions();
Document doc = new Document(stream, opts);
doc.Save("E:\\Temp\\TEST\\20.4.docx");

So, this seems to be an expected behavior. Please let me know if I can be of any further assistance.