Convert Html string to WordXML in MemoryStream

Hi

i got a problem with Aspose Word when convert Html to WordXML. it work fine when save to xml file. but i want to save it to MemoryStream and put to DB as Byte[]. it’s not work as expected. got 3 bytes before of Xml tag and display not correct format.

i attached 2 files in attachment.

and this is the byte[] save from MemoryStream:

<?xml version="1.0" encoding="utf-8" standalone="yes"?><?mso-application progid="Word.Document"?><w:wordDocument …<w:pgMar w:header="720" w:footer="720" /><w:cols w:space="720" /></w:sectPr></wx:sect></w:body></w:wordDocument>

highlight are the wierd characters.

Source Code:
Save directly to file (work fine)

Document doc = new Document("htmlfile");

doc.Save(targetFile, SaveFormat.WordML);
Save directly to MemoryStream(not work as expected)
Document doc = new Document("htmlfile");

doc.Save(memoryStream, SaveFormat.WordML);

please help…
thanks

Alex

Hi

I did some investigation and found that format Bullet symbol cannot convert to byte[] properly when save to MemoryStream. could any body help with this…

Alex

Hi Alex,

Thanks for your inquiry. We have noticed that you’ve generated these files using a very old version of Aspose.Words for .NET i.e. 10.0.0.0. We always encourage our customers to use the latest version of Aspose.Words as it contains newly introduced features, enhancements and fixes to the issues that are reported earlier. Please try upgrading to the latest version 14.8.0 from the following link and see how it goes on your end. I hope, this helps.
https://releases.aspose.com/words/net

Best regards,

Hi Alex,

In addition to my last reply, could you please also attach your input HTML document here for testing? How did you save ‘memoryStream’ object to ‘SaveToMemoryStream.xml’ file on disk? Please attach complete source code. We will investigate the issue on our end and provide you more information.

Best regards,

hi

i tried to download latest version and it even cannot convert to WordML. (html instead), i attach the source please help to check.

please also help to check if save to memoryStream work fine

Hi Alex,

Thanks for the additional information. I am afraid, I could not even see ‘’ marks at the beginning when viewing ‘SaveToMemoryStream.xml’ with MS Word 2013 or ‘Visual Studio’ or ‘Windows 7 Notepad’ for example. What XML editor/viewer are you using on your end? Do you see these marks in attached ‘test.xml’ file also? Also, please see the following article to be able to save Document to stream:
https://docs.aspose.com/words/net/save-a-document/

Best regards,

hi

I removed the weird characters before save it to Xml. that’s why you cannot see those chars in the file. otherwise cannot not open that file in MS word.

i try a new version in previous post and the version 14.XX cannot convert to worldML. please help to check… the format i want is WorldML…

thanks
Alex

Hi Alex,

Thanks for your inquiry. Could you please attach your input document (you are getting this problem with during converting to WordML) here for testing? We will investigate the issue on our end and provide you more information.

Best regards,

hi

please check attachment for the input document

Alex

Hi Alex,

Thanks for your inquiry. Please try executing the following code to convert this Html to WordML format:

LoadOptions loadOptions = new LoadOptions();
loadOptions.LoadFormat = LoadFormat.Html;
Document doc = new Document(MyDir + @"t.html", loadOptions);
doc.Save(MyDir + @"out.xml", SaveFormat.WordML);

I hope, this helps.

Best regards,