Class Settings
Class represents settings of the document.
Inheritance
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class Settings : Object
Properties
CompatibilityMode
Gets or sets the compatibility mode for the document.
Declaration
public CompatibilityMode CompatibilityMode { get; set; }
Property Value
Type | Description |
---|---|
CompatibilityMode | The compatibility mode. |
DisableMovingEntireField
Gets or sets whether the entire field entities or only WField instance should be added. The default is false.
Declaration
public bool DisableMovingEntireField { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if add only WField instance; Otherwise false. |
DisplayBackgrounds
Gets or sets a value indicating whether to shown the background colors and images in print layout view. Default value is false.
Declaration
public bool DisplayBackgrounds { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
The DisplayBackgrounds property corresponds to the Background colors and images (Print view only) option located on the View tab of the Options dialog box. This property is enabled automatically while setting the document background property.
Examples
//Load an existing Word document into DocIO instance.
WordDocument document = new WordDocument("Template.docx");
//Set the background type of the document.
document.Background.Type = BackgroundType.Color;
//Set the background color of the document.
document.Background.Color = Color.Red;
//Sets whether background colors and images are shown when a document is displayed in print layout view.
document.Settings.DisplayBackgrounds = false;
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance.
Dim document As New WordDocument("Template.docx")
'Set the background type of the document.
document.Background.Type = BackgroundType.Color
'Set the background color of the document.
document.Background.Color = Color.Red
'Sets whether background colors and images are shown when a document is displayed in print layout view.
document.Settings.DisplayBackgrounds = False
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
MaintainFormattingOnFieldUpdate
Gets or sets the value indicates whether to maintain the formatting of the field result during field update. Default value is false.
Declaration
public bool MaintainFormattingOnFieldUpdate { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Sets the maintain formatting option to the fields of the Word document
document.Settings.MaintainFormattingOnFieldUpdate = true;
//Updates the document fields
document.UpdateDocumentFields();
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Sets the maintain formatting option to the fields of the Word document
document.Settings.MaintainFormattingOnFieldUpdate = True
'Updates the document fields
document.UpdateDocumentFields()
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()
MaintainImportedListCache
Gets or sets a value indicating whether to maintain information about imported list styles in this document. Default value is false
Declaration
public bool MaintainImportedListCache { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True: if the information about imported list styles are preserved in this document; otherwise, false. |
Remarks
This property is used for defining list restart behavior and avoid importing of duplicate list styles in the scenario of cloning and merging independent elements to this document. Setting it to true, the document preserves information about imported list styles. Setting it to false, the document doesn't preserve any information about imported list styles.
Examples
The following code example demonstrates how to preserve information about imported list styles in this document.
//Opens the source document
WordDocument sourceDocument = new WordDocument("sourceFileName.docx");
//Opens the destination document
WordDocument destinationDocument = new WordDocument("targetFileName.docx");
//Sets true value to maintain imported list style cache to destination document
destinationDocument.Settings.MaintainImportedListCache = true;
//Processes the body contents for each section in the Word document
foreach (WSection section in sourceDocument.Sections)
{
//Accesses the body of section where all the contents in document are apart
foreach (TextBodyItem bodyItem in section.Body.ChildEntities)
{
destinationDocument.LastSection.Body.ChildEntities.Add(bodyItem.Clone());
}
}
//Closes the source document
sourceDocument.Close();
//Sets false value to exclude imported list style cache to destination document
destinationDocument.Settings.MaintainImportedListCache = false;
//Saves the destination document
destinationDocument.Save("outputFileName.docx", FormatType.Docx);
//Closes the destination document
destinationDocument.Close();
'Opens the source document
Dim sourceDocument As New WordDocument(sourceFileName)
'Opens the destination document
Dim destinationDocument As New WordDocument(targetFileName)
'Sets true value to maintain imported list style cache to destination document
destinationDocument.Settings.MaintainImportedListCache = True
'Processes the body contents for each section in the Word document
For Each section As WSection In sourceDocument.Sections
'Accesses the body of section where all the contents in document are apart
For Each bodyItem As TextBodyItem In section.Body.ChildEntities
destinationDocument.LastSection.Body.ChildEntities.Add(bodyItem.Clone())
Next
Next
'Closes the source document
sourceDocument.Close()
'Sets false value to exclude imported list style cache to destination document
destinationDocument.Settings.MaintainImportedListCache = False
'Saves the destination document
destinationDocument.Save(outputFileName, FormatType.Docx)
'Closes the destination document
destinationDocument.Close()
PreserveOleImageAsImage
Gets or sets a value that indicates whether to preserve embedded OLE images as normal images. Default value is false.
Declaration
public bool PreserveOleImageAsImage { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
//Creates an empty Word document instance
WordDocument document = new WordDocument();
//Sets flag to preserve embedded Ole images as normal image while opening document
document.Settings.PreserveOleImageAsImage = true;
//Loads or opens an existing Word document
document.Open(fileName, FormatType.Automatic);
//Saves the resultant Word document
document.Save("Sample.docx", FormatType.Docx);
//Closes the Word document
document.Close();
'Creates an empty Word document instance
Dim document As New WordDocument()
'Sets flag to preserve embedded Ole images as normal image while opening document
document.Settings.PreserveOleImageAsImage = True
'Loads or opens an existing Word document
document.Open("Template.docx", FormatType.Automatic)
'Saves the resultant Word document
document.Save("Sample.docx", FormatType.Docx)
'Closes the Word document
document.Close()
SkipIncrementalSaveValidation
Gets or sets the value indicates whether to skip the Complex format is not supported exception while opening an incrementally saved (*.doc) Word document. Default value is false
Declaration
public bool SkipIncrementalSaveValidation { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True: if need to skip the exception when a Word document have incremental save information while opening; otherwise, False. |
Remarks
Setting the SkipIncrementalSaveValidation property as true, skips the Complex format is not supported exception and reads the document content present in the last complete save operation alone. The recently edited content saved as incremental save using older Microsoft Word application can't be retained.
Examples
//Creates new instance of WordDocument class.
WordDocument document = new WordDocument();
//Sets flag to skip old file format exception while opening document.
document.Settings.SkipIncrementalSaveValidation = true;
//Opens an existing document from file system through.
document.Open("Template.docx", FormatType.Automatic);
//Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Creates new instance of WordDocument class.
Dim document As New WordDocument()
'Sets flag to skip old file format exception while opening document.
document.Settings.SkipIncrementalSaveValidation = True
'Opens an existing document from file system through.
document.Open(fileName, FormatType.Automatic)
'Save and Close the Word document.
document.Save("Sample.docx", FormatType.Docx)
document.Close()
UpdateResultOnFieldCodeChange
Gets or sets the value indicates whether to update the merge field result when field code is modified. Default value is true.
Declaration
public bool UpdateResultOnFieldCodeChange { get; set; }
Property Value
Type |
---|
System.Boolean |
Examples
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template.docx");
//Sets whether result code must be updated when field code is modified.
document.Settings.UpdateResultOnFieldCodeChange = true;
//Modifies the merge field code.
(document.LastParagraph.ChildEntities[0] as WMergeField).FieldCode = "MERGEFIELD Employee_ID \\*MERGEFORMAT";
//Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template.docx")
'Sets whether result code must be updated when field code is modified.
document.Settings.UpdateResultOnFieldCodeChange = True
'Modifies the merge field code.
(document.LastParagraph.ChildEntities[0] as WMergeField).FieldCode = "MERGEFIELD Employee_ID \\*MERGEFORMAT"
'Save and Close the Word document
document.Save("Sample.docx", FormatType.Docx)
document.Close()