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

Free Support Forum - aspose.com

Document Save to Html problems for SaveOptions

Hi,

We upgraded the Aspose.Words.dll from version 9.1.0.0 to version 9.5.0.0

We now can't compile the following code. The SaveOptions have changed and i can't seem to set the properties HtmlExportXhtmlTransitional and HtmlExportCssStyleSheetType when saving to HTML.

Example code:

Document f_Document = new Document();
//do some stuff with the document

//Method 1 // Previous working method use in v9.1.0.0
f_Document.SaveOptions.HtmlExportXhtmlTransitional = true;
f_Document.SaveOptions.HtmlExportCssStyleSheetType = Aspose.Words.Saving.CssStyleSheetType.Embedded;
f_Document.Save(m_TargetDocumentHtml, SaveFormat.Html);

//Method 2 // How to be used in v9.5.0.0 ???
Aspose.Words.Saving.SaveOptions saveOptions;
saveOptions = Aspose.Words.Saving.SaveOptions.CreateSaveOptions(SaveFormat.Html);
saveOptions. //Doesnt contain HtmlExportXhtmlTransitional or HtmlExportCssStyleSheetType
f_Document.Save(m_TargetDocumentHtml, saveOptions);

Please how do i set the saveoptions HtmlExportXhtmlTransitional and HtmlExportCssStyleSheetType ??

Please advice. Thanks in advance.

Jan Stolk

Dear Jan,

Thank you for your request.

Indeed, there were some changes in the Aspose.Words public API starting from 9.2.0.0 version:

Document.SaveOptions property was deleted. Save options are now passed as a parameter to the Document.Savemethods. TheSaveOptions class has been split into several classes one for each save format. All property names have been simplified.


Under these changes I would suggest the following code fragment to use with 9.5.0.0 version:

Document f_Document = new Document();
//do some stuff with the document

//Method 2 // How to be used in v9.5.0.0
HtmlSaveOptions saveOptions = new HtmlSaveOptions(SaveFormat.Html);
saveOptions.ExportXhtmlTransitional = true;
saveOptions.CssStyleSheetType = CssStyleSheetType.Embedded;
f_Document.Save(m_TargetDocumentHtml, saveOptions);

Please try it. Hope it is what you need.

For more information about HtmlSaveOptions please see here http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.saving.htmlsaveoptions.html


Upd: Just to notify you: at latest Aspose.Words version 9.5.0.0 it was added DocumentSplitCriteria property which specifies how the document should be split when saving to Html or Epub format http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.saving.htmlsaveoptions.documentsplitcriteria.html