ImportFormatOptions Class

Allows to specify various import options to format output.
Inheritance Hierarchy

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.2
public class ImportFormatOptions

The ImportFormatOptions type exposes the following members.

Public methodImportFormatOptions
Initializes a new instance of the ImportFormatOptions class
Public propertyCode exampleIgnoreTextBoxes
Gets or sets a boolean value that indicates whether to ignore formatting in the text boxes of the source destination during the import. Default value is true.
Public propertyCode exampleKeepSourceNumbering
Gets or sets a boolean value that specifies how the numbering will be imported when it clashes in source and destination documents. The default value is false.
Public propertyCode exampleSmartStyleBehavior
Gets or sets a boolean value that specifies how styles will be imported when they have equal names in source and destination documents. The default value is false.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Shows how to resolve styles behavior while inserting documents.
Document dstDoc = new Document();
DocumentBuilder builder = new DocumentBuilder(dstDoc);

Style myStyle = builder.Document.Styles.Add(StyleType.Paragraph, "MyStyle");
myStyle.Font.Size = 14;
myStyle.Font.Name = "Courier New";
myStyle.Font.Color = Color.Blue;

// Append text with custom style
builder.ParagraphFormat.StyleName = myStyle.Name;
builder.Writeln("Hello world!");

// Clone the document, and edit the clone's "MyStyle" style so it is a different color than that of the original
// If we append this document to the original, the different styles will clash since they are the same name, and we will need to resolve it
Document srcDoc = dstDoc.Clone();
srcDoc.Styles["MyStyle"].Font.Color = Color.Red;

// When SmartStyleBehavior is enabled,
// a source style will be expanded into a direct attributes inside a destination document,
// if KeepSourceFormatting importing mode is used
ImportFormatOptions options = new ImportFormatOptions();
options.SmartStyleBehavior = true;

builder.InsertDocument(srcDoc, ImportFormatMode.KeepSourceFormatting, options);

dstDoc.Save(ArtifactsDir + @"DocumentBuilder.SmartStyleBehavior.docx");
See Also