Save doc to htm loss of space in front mergefield

We need to transform a document doc to retrieve content in htm format. This word document contains merge filed. But we execute the following code during processing, format merge field on pert and spaces before the merge fiedl randomly.We need to transform a document doc to retrieve content in htm format. This word document contains merge filed. But we execute the following code during processing, format merge field on pert and spaces before the merge fiedl randomly.

MemoryStream lItmTemplate = new MemoryStream(aContenuBinaire);

MemoryStream lItm = new MemoryStream();

//Set license

Aspose.Words.

License license = new Aspose.Words.License();

license.SetLicense(

"Aspose.Total.lic");

//lit le document

Aspose.Words.

Document lDoc = new Aspose.Words.Document(lItmTemplate);

//on enregistre au format html

Aspose.Words.Saving.

HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(Aspose.Words.SaveFormat.Html);

saveOptions.ImagesFolderAlias =

Path.GetTempPath();

saveOptions.ExportImagesAsBase64 =

true;

lDoc.Save(lItm, saveOptions);

//on le lit

lItm.Seek(0,

SeekOrigin.Begin);

StreamReader lReader = new StreamReader(lItm);

string lOutputText = lReader.ReadToEnd();

lReader.Close();

//on renvoye le contenu sous forme de string contenant de l'html

return lOutputText;

v

Hi Alain,

Thanks for your inquiry. It would be great if you please share following detail for investigation purposes.


  • Please attach your input Word document.
  • Please attach the output HTML file that shows the undesired behavior.

As soon as you get these pieces of information to
us we’ll start our investigation into your issue.

We need to transform a document doc to retrieve content in htm format. This word document contains merge filed. But we execute the following code during processing, format merge field on pert and spaces before the merge fiedl randomly.We need to transform a document doc to retrieve content in htm format. This word document contains merge filed. But we execute the following code during processing, format merge field on pert and spaces before the merge fiedl randomly.

MemoryStream lItmTemplate = new MemoryStream(aContenuBinaire);

MemoryStream lItm = new MemoryStream();

//Set license

Aspose.Words.

License license = new Aspose.Words.License();

license.SetLicense(

“Aspose.Total.lic”);

//lit le document

Aspose.Words.

Document lDoc = new Aspose.Words.Document(lItmTemplate);

//on enregistre au format html

Aspose.Words.Saving.

HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(Aspose.Words.SaveFormat.Html);

saveOptions.ImagesFolderAlias =

Path.GetTempPath();

saveOptions.ExportImagesAsBase64 =

true;

lDoc.Save(lItm, saveOptions);

//on le lit

lItm.Seek(0,

SeekOrigin.Begin);

StreamReader lReader = new StreamReader(lItm);

string lOutputText = lReader.ReadToEnd();

lReader.Close();

//on renvoye le contenu sous forme de string contenant de l’html

return lOutputText;

We need to transform a document doc to retrieve content in htm format. This word document contains merge filed. But we execute the following code during processing, format merge field on pert and spaces before the merge fiedl randomly.We need to transform a document doc to retrieve content in htm format. This word document contains merge filed. But we execute the following code during processing, format merge field on pert and spaces before the merge fiedl randomly. Attached are two files requestedAttached are two files requested

MemoryStream lItmTemplate = new MemoryStream(aContenuBinaire);

MemoryStream lItm = new MemoryStream();

//Set license

Aspose.Words.

License license = new Aspose.Words.License();

license.SetLicense(

“Aspose.Total.lic”);

//lit le document

Aspose.Words.

Document lDoc = new Aspose.Words.Document(lItmTemplate);

//on enregistre au format html

Aspose.Words.Saving.

HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions(Aspose.Words.SaveFormat.Html);

saveOptions.ImagesFolderAlias =

Path.GetTempPath();

saveOptions.ExportImagesAsBase64 =

true;

lDoc.Save(lItm, saveOptions);

//on le lit

lItm.Seek(0,

SeekOrigin.Begin);

StreamReader lReader = new StreamReader(lItm);

string lOutputText = lReader.ReadToEnd();

lReader.Close();

//on renvoye le contenu sous forme de string contenant de l’html

return lOutputText;

Hi there,

Thanks for sharing the detail. Please note that Aspose.Words mimics the same behaviour as MS Word does.

I have tested the scenario and have not found the shared issue while using latest version of Aspose.Words. Please upgrade to the latest version of Aspose.Words for .NET 14.3.0. I have attached the output html with this post for your kind reference.