Aspose::Words::ImportFormatOptions class

ImportFormatOptions class

Allows to specify various import options to format output. To learn more, visit the Specify Load Options documentation article.

class ImportFormatOptions : public System::Object

Methods

MethodDescription
ImportFormatOptions()
get_AdjustSentenceAndWordSpacing() constGets or sets a boolean value that specifies whether to adjust sentence and word spacing automatically. The default value is false.
get_AppendDocumentWithNewPage() constGets or sets a boolean value indicating whether to change a first imported section type to the NewPage forcibly when call AppendDocument().
The default value is true.
get_ForceCopyStyles() constGets or sets a boolean value indicating either to copy conflicting styles in KeepSourceFormatting mode. The default value is false.
get_IgnoreHeaderFooter() constGets or sets a boolean value that specifies that source formatting of headers/footers content ignored if KeepSourceFormatting mode is used. The default value is true.
get_IgnoreTextBoxes() constGets or sets a boolean value that specifies that source formatting of textboxes content ignored if KeepSourceFormatting mode is used. The default value is true.
get_KeepSourceNumbering() constGets 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.
get_MergePastedLists() constGets or sets a boolean value that specifies whether pasted lists will be merged with surrounding lists. The default value is false.
get_ResolveThemeColors() constGets or sets a boolean value that specifies whether to resolve theme colors of the shapes forcibly. The default value is false.
get_SmartStyleBehavior() constGets 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.
set_AdjustSentenceAndWordSpacing(bool)Sets a boolean value that specifies whether to adjust sentence and word spacing automatically. The default value is false.
set_AppendDocumentWithNewPage(bool)Sets a boolean value indicating whether to change a first imported section type to the NewPage forcibly when call AppendDocument().
The default value is true.
set_ForceCopyStyles(bool)Sets a boolean value indicating either to copy conflicting styles in KeepSourceFormatting mode. The default value is false.
set_IgnoreHeaderFooter(bool)Sets a boolean value that specifies that source formatting of headers/footers content ignored if KeepSourceFormatting mode is used. The default value is true.
set_IgnoreTextBoxes(bool)Sets a boolean value that specifies that source formatting of textboxes content ignored if KeepSourceFormatting mode is used. The default value is true.
set_KeepSourceNumbering(bool)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.
set_MergePastedLists(bool)Sets a boolean value that specifies whether pasted lists will be merged with surrounding lists. The default value is false.
set_ResolveThemeColors(bool)Sets a boolean value that specifies whether to resolve theme colors of the shapes forcibly. The default value is false.
set_SmartStyleBehavior(bool)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.

auto dstDoc = System::MakeObject<Aspose::Words::Document>();
auto builder = System::MakeObject<Aspose::Words::DocumentBuilder>(dstDoc);

System::SharedPtr<Aspose::Words::Style> myStyle = builder->get_Document()->get_Styles()->Add(StyleType::Paragraph, u"MyStyle");
myStyle->get_Font()->set_Size(14);
myStyle->get_Font()->set_Name(u"Courier New");
myStyle->get_Font()->set_Color(System::Drawing::Color::get_Blue());

builder->get_ParagraphFormat()->set_StyleName(myStyle->get_Name());
builder->Writeln(u"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.
System::SharedPtr<Aspose::Words::Document> srcDoc = dstDoc->Clone();
srcDoc->get_Styles()->idx_get(u"MyStyle")->get_Font()->set_Color(System::Drawing::Color::get_Red());

// 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.
auto options = System::MakeObject<Aspose::Words::ImportFormatOptions>();
options->set_SmartStyleBehavior(true);

builder->InsertDocument(srcDoc, ImportFormatMode::KeepSourceFormatting, options);

dstDoc->Save(get_ArtifactsDir() + u"DocumentBuilder.SmartStyleBehavior.docx");

See Also