Aspose.Words使用教程之如何操作主題屬性

  我們已經在Aspose.Words 15.7.0添加了基本API來訪問文檔的主題屬性,現在,這API包括以下幾個公共對象:

  • 主題

  • 主題字體

  • 主題顏色

以下介紹如何獲取主題屬性:

C#

Document doc = new Document(MyDir + @"in.docx");
Theme theme = doc.Theme;
Console.WriteLine(theme.MajorFonts.Latin); // Major (Headings) font for Latin characters.
Console.WriteLine(theme.MinorFonts.EastAsian);    // Minor (Body) font for EastAsian characters.
Console.WriteLine(theme.Colors.Accent1);          // Color for theme color Accent 1.

Visual Basic

Dim doc As New Document(MyDir & "in.docx")
Dim theme As Theme = doc.Theme
Console.WriteLine(theme.MajorFonts.Latin) ' Major (Headings) font for Latin characters.
Console.WriteLine(theme.MinorFonts.EastAsian) ' Minor (Body) font for EastAsian characters.

Console.WriteLine(theme.Colors.Accent1) ' Color for theme color Accent 1.

以下介紹如何設置主題屬性:

C#

Document doc = new Document(MyDir + @"in.docx");
Theme theme = doc.Theme;
theme.MinorFonts.Latin = "Times New Roman";     // Set Times New Roman font as Body theme font for Latin Character.
theme.Colors.Hyperlink = Color.Gold;            // Set Color.Gold for theme color Hyperlink.

Visual Basic

Dim doc As New Document(MyDir & "in.docx")
Dim theme As Theme = doc.Theme
theme.MinorFonts.Latin = "Times New Roman" ' Set Times New Roman font as Body theme font for Latin Character.
theme.Colors.Hyperlink = Color.Gold ' Set Color.Gold for theme color Hyperlink.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章