Currently using this to edit the theme, but I want to select from existing custom themes and rename the current theme
theme = doc.theme
colors = theme.colors
Currently using this to edit the theme, but I want to select from existing custom themes and rename the current theme
theme = doc.theme
colors = theme.colors
To select a new theme instead of modifying the existing one in Aspose.Words, you can set the theme properties directly on your Document object. Unfortunately, the provided context does not specify a method to select from existing custom themes, but you can create a new theme by defining the properties you want.
Here’s a general approach to set a new theme:
Theme
property of the Document class to access the theme settings.Here’s a code example demonstrating how to set new theme properties:
using Aspose.Words;
using System.Drawing;
class Program
{
static void Main()
{
// Create a new document
Document doc = new Document();
// Access the theme object
Aspose.Words.Themes.Theme theme = doc.Theme;
// Set new theme properties
theme.MajorFonts.Latin = "Arial";
theme.MinorFonts.Latin = "Times New Roman";
theme.Colors.Accent1 = Color.Blue;
theme.Colors.Hyperlink = Color.Red;
// Save the document
doc.Save("NewDocumentWithTheme.docx");
}
}
In this example, you create a new document and set the major and minor fonts along with accent colors. If you have existing custom themes, you would need to manually set the properties based on those themes, as the API does not provide a direct method to select from them.
For more detailed information on working with themes, you can refer to the Aspose.Words documentation on manipulating theme properties.
If you need further assistance or specific examples, feel free to ask!
Sources:
[1]: Get Document Theme Properties In Word | Aspose.Words Document …
[2]: Working with Styles and Themes|Aspose.Words for Java
I’m referring to this themes.
@Mark030 Could you please attach your input and expected output documents here for our reference? We will check them and provide you more information.
By default Custom 1 is selected as theme. So I want to select Custom 3 instead
@Mark030 I am afraid, your requirements are still not clear enough. If possible, could you please provide you sample input and expected output to make it more clear.