Class SaveOptions
Represents the document saving options.
Inheritance
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public class SaveOptions : Object
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
HtmlExportBodyContentAlone
Declaration
public bool HtmlExportBodyContentAlone { get; set; }
Property Value
Type |
---|
System.Boolean |
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.
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. |
MarkdownExportImagesFolder
Gets or sets the physical folder to save the images when exporting a Word document to Markdown format. By default, it is empty.
Declaration
public string MarkdownExportImagesFolder { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the physical folder to save the image. |
Remarks
This property is only applicable while exporting the Word document as Markdown file. This property is not applicable for .NET MAUI, Xamarin and UWP.
Exceptions
Type | Condition |
---|---|
System.Exception | Given physical folder not accessible to export the images. Enable permission if access is denied. |
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 |
---|
System.Boolean |
Remarks
This property is not supported in UNIVERSAL,UWP,WP and Xamarin application.
Methods
add_ImageNodeVisited(ImageNodeVisitedEventHandler)
Declaration
public void add_ImageNodeVisited(ImageNodeVisitedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ImageNodeVisitedEventHandler | value |
remove_ImageNodeVisited(ImageNodeVisitedEventHandler)
Declaration
public void remove_ImageNodeVisited(ImageNodeVisitedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ImageNodeVisitedEventHandler | value |
Events
ImageNodeVisited
Declaration
public event ImageNodeVisitedEventHandler ImageNodeVisited
Event Type
Type |
---|
ImageNodeVisitedEventHandler |