文檔首頁(yè)>>Aspose.Words使用教程>>Aspose.Words使用教程之如何操作主題屬性
Aspose.Words使用教程之如何操作主題屬性
我們已經(jīng)在Aspose.Words 15.7.0添加了基本API來(lái)訪問(wèn)文檔的主題屬性,現(xiàn)在,這API包括以下幾個(gè)公共對(duì)象:
- 主題
- 主題字體
- 主題顏色
以下介紹如何獲取主題屬性:
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.
以下介紹如何設(shè)置主題屬性:
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.