Aspose::Words::ImportFormatOptions::get_ResolveThemeColors method

ImportFormatOptions::get_ResolveThemeColors method

Gets or sets a boolean value that specifies whether to resolve theme colors of the shapes forcibly. The default value is false.

bool Aspose::Words::ImportFormatOptions::get_ResolveThemeColors() const

Remarks

Please note that this option is only relevant for the KeepSourceFormatting mode.

Normally, Aspose.Words doesn’t resolve source theme colors when importing styles can be preserved without expanding formatting attributes into direct ones. However, in this case the actual colors of the imported shapes can differ from the ones they had in the original document. The reason for this is the different theme colors in the source and destination documents. Setting this option to true forces to resolve source shape theme colors and hence to preserve the actual color of the shapes they have in the source document.

Examples

Shows how to import a node with resolving source theme colors of shapes.

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

// Move to the primary footer and insert a shape that uses theme colors.
builder->MoveToHeaderFooter(HeaderFooterType::FooterPrimary);
System::SharedPtr<Aspose::Words::Drawing::Shape> shape = builder->InsertShape(ShapeType::Rectangle, static_cast<double>(100), static_cast<double>(50));
shape->get_Stroke()->set_ForeThemeColor(ThemeColor::Dark1);

auto dstDoc = System::MakeObject<Aspose::Words::Document>();
// Import the source footer into the destination document with theme colors resolved,
// so the shape preserves its actual color from the source document.
System::SharedPtr<Aspose::Words::HeaderFooter> footer = srcDoc->get_FirstSection()->get_HeadersFooters()->idx_get(HeaderFooterType::FooterPrimary);

auto options = System::MakeObject<Aspose::Words::ImportFormatOptions>();
options->set_ResolveThemeColors(true);
auto importedFooter = System::ExplicitCast<Aspose::Words::HeaderFooter>(dstDoc->ImportNode(footer, true, ImportFormatMode::KeepSourceFormatting, options));

dstDoc->get_FirstSection()->get_HeadersFooters()->Add(importedFooter);

dstDoc->Save(get_ArtifactsDir() + u"DocumentBase.ImportNodeWithResolveThemeColors.docx");

See Also