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

Free Support Forum - aspose.com

Docx to HTML formatting question

I'm using the trial version and trying to convert a docx file to HTML.

The line height is off and the indents are missing.

Are there some options that I'm missing?


Hi Gary,

Can you please share your input Word document to reproduce the issue?

Best Regards,

Attached.


And my code below.

static void ExportHTML(string srcFile, string path)
{
var doc = new Document(srcFile);
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.DocumentSplitCriteria = DocumentSplitCriteria.PageBreak;
saveOptions.SaveFormat = SaveFormat.Html;
string outFile = srcFile.Replace(“docx”, “html”);
doc.Save(outFile, saveOptions);
}

Hi Gary,

Sorry, I was not able to notice any difference in the output HTML using the latest version of Aspose.Words for .NET. Can you please share a screenshot to highlight the issue?

Best Regards,

Hi Gary,

This is expected behavior as MS Word also produces the same output. You can follow http://www.aspose.com/docs/display/wordsnet/Specifying+Formatting to update paragraph formatting or page setup and get your desired result.

Best Regards,

I’m not sure how that applies. I’m not building a document object, I’m converting an existing document to HTML using document.Save with the SaveFormat set to HTML.


The spacing also seems to differ between browsers, i.e. it looks different in Chrome and various flavors of IE.

Hi Gary,

In your case, you can save your document to Html_Fixed format e.g.

doc.Save("SunTrust_GreatDayatWork_Email_Content_v2.1-1.html", SaveFormat.HtmlFixed);

Best Regards,

I get “An invalid SaveFormat for this options type was chosen.”


HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.DocumentSplitCriteria = DocumentSplitCriteria.PageBreak;
saveOptions.SaveFormat = SaveFormat.HtmlFixed;
string outFile = srcFile.Replace(extension, “.html”);
doc.Save(filesDir + “/” + outFile, saveOptions);

Hi Gary,

You cannot use HtmlSaveOptions with HtmlFixed format. Please use HtmlFixedSaveOptions as you can see in the following example.

HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions();

saveOptions.PageCount = 1;

<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

for (int i = 0; i < doc.PageCount; i++)

{

saveOptions.PageIndex = i;

doc.Save(@"SunTrust_GreatDayatWork_Email_Content_v2.1-1_Page"+(i+1)+".html", saveOptions);

}

Best Regards,