Skip to main content

Document.Theme Property

Gets or sets the theme used in the document.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v23.2.Core.dll

NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation

Declaration

IDocumentTheme Theme { get; set; }

Property Value

Type Description
IDocumentTheme

An object implementing the IDocumentTheme interface that is the document theme.

Remarks

Use the Theme property to obtain or assign a theme used in the document. A document theme contains two sets of fonts (Headings and Body) for the entire document. Each set includes font names for different languages. You can retrieve or specify the theme fonts information.

The DocumentTheme is the default IDocumentTheme interface implementation that represents the document theme. The DocumentTheme class properties allow you to specify font names for East Asian, Latin and Complex Script languages.

The code sample below shows how to create a new DocumentTheme object and pass it as the Document.Theme property value:

//Create a new DocumentTheme object:
DocumentTheme theme = new DocumentTheme();

//Specify Body and Heading fonts for Complex Script...
theme.BodyComplexScript = "Microsoft Sans Serif";
theme.HeadingsComplexScript = "Tahoma";

//...Latin...
theme.HeadingsLatin = "Segoe UI Semilight";
theme.BodyLatin = "Times New Roman";

//..and East Asian languages:
theme.HeadingsEastAsia = "DengXian Light";
theme.BodyEastAsia = "DengXian";

//Set the created object as the Theme property value:
doc.Theme = theme;

// Specify theme font types used for Complex Script and East Asian languages:
CharacterProperties fontProperties = doc.BeginUpdateCharacters(doc.Range);

fontProperties.ThemeFontComplexScript = ThemeFont.HeadingsComplexScript;
fontProperties.ThemeFontEastAsia = ThemeFont.BodyEastAsia;

doc.EndUpdateCharacters(fontProperties);


//Save the result:
doc.SaveDocument("123456.docx", DocumentFormat.OpenXml);
See Also