Class SaveOptions
Represents the document saving options.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class SaveOptions
Examples
The following code snippet shows how to customize Word to HTML conversion using SaveOptions.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Loads an existing document
WordDocument document = new WordDocument("Template.docx");
HTMLExport export = new HTMLExport();
//The images in the input document will be copied to this folder
document.SaveOptions.HtmlExportImagesFolder = @"D:\Data\";
//The headers and footers in the input will be exported
document.SaveOptions.HtmlExportHeadersFooters = true;
//Export the text form fields as editable
document.SaveOptions.HtmlExportTextInputFormFieldAsText = false;
//Set the style sheet type
document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.External;
//Set name for style sheet
document.SaveOptions.HtmlExportCssStyleSheetFileName = "UserDefinedFileName.css";
//Save the document as html file
export.SaveAsXhtml(document, "WordtoHtml.html");
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Loads an existing document
Dim document As New WordDocument("Template.docx")
Dim export As New HTMLExport()
'The images in the input document will be copied to this folder
document.SaveOptions.HtmlExportImagesFolder = "D:\Data\"
'The headers and footers in the input will be exported
document.SaveOptions.HtmlExportHeadersFooters = True
'Export the text form fields as editable
document.SaveOptions.HtmlExportTextInputFormFieldAsText = False
'Set the style sheet type
document.SaveOptions.HtmlExportCssStyleSheetType = CssStyleSheetType.External
'Set name for style sheet
document.SaveOptions.HtmlExportCssStyleSheetFileName = "UserDefinedFileName.css"
'Save the document as html file
export.SaveAsXhtml(document, "WordtoHtml.html")
document.Close()
End Sub
The following code snippet shows how to customize Word to EPub file conversion using SaveOptions.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing document
WordDocument document = new WordDocument("Template.docx", FormatType.Docx);
//Export the fonts used in the document
document.SaveOptions.EPubExportFont = true;
//Export header and footer
document.SaveOptions.HtmlExportHeadersFooters = true;
//Save the document as EPub file
document.Save("WordToEPub.epub", FormatType.EPub);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing document
Dim document As New WordDocument("Template.docx", FormatType.Docx)
'Export the fonts used in the document
document.SaveOptions.EPubExportFont = True
'Export header and footer
document.SaveOptions.HtmlExportHeadersFooters = True
'Save the document as EPub file
document.Save("WordToEPub.epub", FormatType.EPub)
'Close the document
document.Close()
End Sub
The following code snippet shows how to preserve compatibility mode as in the input Word document using SaveOptions.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing document
WordDocument document = new WordDocument("Template.doc", FormatType.Doc);
//Preserve compatibility mode as in the input Word document
document.SaveOptions.MaintainCompatibilityMode = true;
//Save the document as Docx file
document.Save("Result.docx", FormatType.Docx);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing document
Dim document As New WordDocument("Template.doc", FormatType.Doc)
'Export the fonts used in the document
document.SaveOptions.EPubExportFont = True
'Preserve compatibility mode as in the input Word document
document.SaveOptions.MaintainCompatibilityMode = True
'Save the document as Docx file
document.Save("Result.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
Constructors
SaveOptions()
Declaration
public SaveOptions()
Properties
EPubExportFont
Gets or sets a value indicating whether the font should be embedded in EPub.
Declaration
public bool EPubExportFont { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the font should be embedded in EPub; otherwise, false. |
Remarks
This property is not supported in UWP, MVC6 and Xamarin application.
HtmlExportCssStyleSheetFileName
Gets or sets the name of the HTML export CSS style sheet file.
Declaration
public string HtmlExportCssStyleSheetFileName { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the HTML export CSS style sheet file name. |
Remarks
This property is not supported in MVC6 and Xamarin application. This property is only applicable while exporting the Word document as HTML file.
HtmlExportCssStyleSheetType
Gets or sets the type of the HTML export CSS style sheet.
Declaration
public CssStyleSheetType HtmlExportCssStyleSheetType { get; set; }
Property Value
Type | Description |
---|---|
CssStyleSheetType | The CssStyleSheetType member that specifies the type of the HTML export CSS style sheet. |
Remarks
This property is only applicable while exporting the Word document as HTML file.
HtmlExportHeadersFooters
Gets or sets a value indicating whether to include headers and footers while exporting HTML file.
Declaration
public bool HtmlExportHeadersFooters { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to include headers and footers; otherwise false. |
Remarks
The header and footer contents in the first page of the document will be exported as first and last content of the exported HTML file.
HTMLExportImageAsBase64
Declaration
public bool HTMLExportImageAsBase64 { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
HtmlExportImagesFolder
Gets or sets the HTML export images folder for extracing the images in the document.
Declaration
public string HtmlExportImagesFolder { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the name of the images folder. |
Remarks
This property will be considered in HTML exporting if HTMLExportImageAsBase64 property is false.This property is not supported in MVC6 and Xamarin application. This property is only applicable while exporting the Word document as HTML file.
HtmlExportOmitXmlDeclaration
Gets or sets value indicating whether to omit XML declaration in the exported HTML file.
Declaration
public bool HtmlExportOmitXmlDeclaration { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if Omit XML declaration in the exported HTML file; false otherwise. Default value is false. |
HtmlExportTextInputFormFieldAsText
Gets or sets a value indicating whether to export text input form field as text.
Declaration
public bool HtmlExportTextInputFormFieldAsText { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if HTML export text input form field as text; otherwise, false. |
Remarks
By default, the text form fields are preserved as editable fields while exporting the HTML file. This property is only applicable while exporting the Word document as HTML file.
HTMLExportWithWordCompatibility
Gets or sets a value indicating whether the HTML document should be exported with the same rendering as the Word document. Default value is True.
Declaration
public bool HTMLExportWithWordCompatibility { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True to preserve the HTML contents equivalent to the Word document; false otherwise. |
Remarks
This property is only applicable while exporting the Word document as a HTML file.
Examples
//Opens an existing Word document
WordDocument document = new WordDocument("Input.docx");
//Disables a flag to export HTML without WordCompatiblity
document.SaveOptions.HTMLExportWithWordCompatiblity = false;
//Saves the document
document.Save("Output.html", FormatType.Html);
//Closes the document
document.Close();
'Opens an existing Word document
Dim document As WordDocument = New WordDocument("Input.docx")
'Disables a flag to export HTML without WordCompatiblity
document.SaveOptions.HTMLExportWithWordCompatiblity = False
'Saves the document
document.Save("Output.html", FormatType.Html)
'Close the document
document.Close()
MaintainCompatibilityMode
Gets or sets a value indicating whether to preserve compatibility mode as in the input Word document.
Declaration
public bool MaintainCompatibilityMode { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if to have the compatibility mode as preserved in the input document; false if to have the compatibility mode based on the save format type. |
OptimizeRtfFileSize
Gets or sets a value indicating whether to reduce the resultant RTF file size by removing the tags with default values.
Declaration
public bool OptimizeRtfFileSize { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True The resultant rtf file size is reduced false. |
Remarks
The default value is false
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing document
WordDocument document = new WordDocument("Template.rtf", FormatType.Rtf);
//Sets the OptmizedRtfFileSize property as true
document.SaveOptions.OptimizeRtfFileSize = true;
//Save the document as Docx file
document.Save("Result.rtf", FormatType.Rtf);
//Close the document
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing document
Dim document As New WordDocument("Template.rtf", FormatType.Rtf)
'Sets the OptmizedRtfFileSize property as true
document.SaveOptions.OptimizeRtfFileSize = True
'Save the document as Docx file
document.Save("Result.rtf", FormatType.Rtf)
'Close the document
document.Close()
End Sub
UseContextualSpacing
Gets or sets value indicating whether the paragraph contextual spacing should be consider in HTML export.
Declaration
public bool UseContextualSpacing { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
This property is not supported in UNIVERSAL,UWP,WP and Xamarin application.
Events
ImageNodeVisited
Declaration
public event ImageNodeVisitedEventHandler ImageNodeVisited
Event Type
Type | Description |
---|---|
ImageNodeVisitedEventHandler |