ImportFormatOptions class
ImportFormatOptions class
Allows to specify various import options to format output. To learn more, visit the Specify Load Options documentation article.
Constructors
Name | Description |
---|---|
ImportFormatOptions() | The default constructor. |
Properties
Name | Description |
---|---|
adjustSentenceAndWordSpacing | Gets or sets a boolean value that specifies whether to adjust sentence and word spacing automatically. The default value is false . |
forceCopyStyles | Gets or sets a boolean value indicating either to copy conflicting styles in ImportFormatMode.KeepSourceFormatting mode. The default value is false . |
ignoreHeaderFooter | Gets or sets a boolean value that specifies that source formatting of headers/footers content ignored if ImportFormatMode.KeepSourceFormatting mode is used. The default value is true . |
ignoreTextBoxes | Gets or sets a boolean value that specifies that source formatting of textboxes content ignored if ImportFormatMode.KeepSourceFormatting mode is used. The default value is true . |
keepSourceNumbering | 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 . |
mergePastedLists | Gets or sets a boolean value that specifies whether pasted lists will be merged with surrounding lists. The default value is false . |
smartStyleBehavior | 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 . |
Examples
Shows how to resolve duplicate styles while inserting documents.
let dstDoc = new aw.Document();
let builder = new aw.DocumentBuilder(dstDoc);
let myStyle = builder.document.styles.add(aw.StyleType.Paragraph, "MyStyle");
myStyle.font.size = 14;
myStyle.font.name = "Courier New";
myStyle.font.color = "#0000FF";
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 insert the clone into the original document, the two styles with the same name will cause a clash.
let srcDoc = dstDoc.clone().asDocument();
srcDoc.styles.at("MyStyle").font.color = "#FF0000";
// When we enable SmartStyleBehavior and use the KeepSourceFormatting import format mode,
// Aspose.words will resolve style clashes by converting source document styles.
// with the same names as destination styles into direct paragraph attributes.
let options = new aw.ImportFormatOptions();
options.smartStyleBehavior = true;
builder.insertDocument(srcDoc, aw.ImportFormatMode.KeepSourceFormatting, options);
dstDoc.save(base.artifactsDir + "DocumentBuilder.smartStyleBehavior.docx");
See Also
- module Aspose.Words