Free Support Forum - aspose.com

Query regarding Aspose HTML format

Hi,

We are using Aspose Total Lic version 10.0.0.0 to generate word document

In this process we are taking Aspose HTML of the input word document using the following code:

string htmlText = string.Empty;
string lStrImageFolder = string.Empty;
lStrImageFolder = FolderPath + “/” +

ConfigurationManager.AppSettings[“HTMLFileFolderName”].ToString();
string tempDir = Path.Combine(Server.MapPath(lStrImageFolder));
if (!Directory.Exists(tempDir))
Directory.CreateDirectory(tempDir);

Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
saveOptions.ImagesFolder = tempDir;
saveOptions.CssStyleSheetType = Aspose.Words.Saving.CssStyleSheetType.Embedded;
saveOptions.SaveFormat=SaveFormat.Html;
saveOptions.ImagesFolderAlias =

ConfigurationManager.AppSettings[“HTMLFileFolderName”].ToString();
MemoryStream htmlStream = new MemoryStream();
doc.Save(htmlStream, saveOptions);
htmlText = Encoding.UTF8.GetString(htmlStream.GetBuffer());
htmlStream.Close();

In the generated HTML we are facing problem because the data is splitted in multiple span tags.

For example:

Input Text:

switchport trunk allowed vlan <<var_global_mgmt_vlan_id>>,<<var_global_nfs_vlan_id>>

The HTML generated for this input is:


switchport trunk allowed vlan
<<var_global_mgmt_vlan_id>>
,
<<
var_
global_nfs_vlan_id>>




Means in the output the data is splitting in multiple span tags:
<<
var_
global_nfs_vlan_id>>


so is there any way we can get the above data in single span tag like:
<<var_global_nfs_vlan_id>>

PFA file for reference
Please provide the solution asap

Thanks,
Samanvay

Hello

Thanks for your request. This can occur because text in your document consists of multiple Runs. Usually this occurs when you edit document multiple times in MS Word.

There is JoinRunsWithSameFormatting method, which concatenates runs with same formatting. So you can try just calling this method before saving document as HTML.

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.document.joinrunswithsameformatting.html

Best regards,

Thanks for quick response,

It helped