我們已經在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.