We’re pleased to announce the release of Spire.Doc 14.9.1. This version brings powerful new capabilities for Word document theme management, alongside enhanced chart styling and font embedding controls for document export. Developers can now fully customize, duplicate and edit Word document themes programmatically to unify visual styles across multiple files.
Also, two critical conversion and page-deletion bugs have been resolved to enhance overall processing stability. More details are as follows.
Here is a list of changes made in this release
| Category | ID | Description |
| New Feature | SPIREDOC-11492 | Added support for creating custom document themes.
// Create a new document and apply the theme
Document doc = new Document();
// Configure a custom theme
Theme theme = doc.Theme;
theme.MajorFonts.Latin = "Courier New"; // Set the heading font to Courier New
theme.MinorFonts.Latin = "Agency FB"; // Set the body font to Agency FB
ThemeColors colors = theme.Colors;
colors.Dark1 = Color.MidnightBlue;
colors.Light1 = Color.PaleGreen;
colors.Dark2 = Color.Indigo;
colors.Light2 = Color.Khaki;
colors.Accent1 = Color.OrangeRed;
colors.Accent2 = Color.LightSalmon;
colors.Accent3 = Color.Yellow;
colors.Accent4 = Color.Gold;
colors.Accent5 = Color.BlueViolet;
colors.Accent6 = Color.DarkViolet;
colors.Hyperlink = Color.Black;
colors.FollowedHyperlink = Color.Gray;
Section section = doc.AddSection();
// Create a heading and apply MajorFonts and the Accent1 color
Paragraph heading = section.AddParagraph();
heading.AppendText("Document Theme Test");
heading.ApplyStyle(BuiltinStyle.Heading1);
// Link the heading style to MajorFonts
ParagraphStyle heading1Style = (ParagraphStyle)doc.Styles["Heading 1"];
heading1Style.CharacterFormat.ThemeFont = ThemeFont.Major; // Use the Major theme font (heading font)
heading1Style.CharacterFormat.ThemeColor = ThemeColor.Accent1; // Use the Accent1 theme color
// Create a body paragraph and apply MinorFonts
Paragraph body = section.AddParagraph();
body.AppendText("This document uses a custom theme created programmatically.");
// Link the Normal style to MinorFonts
ParagraphStyle normalStyle = (ParagraphStyle)doc.Styles["Normal"];
normalStyle.CharacterFormat.ThemeFont = ThemeFont.Minor; // Use the Minor theme font (body font)
normalStyle.CharacterFormat.ThemeColor = ThemeColor.Text1; // Use the default text color
// Add a test paragraph to verify the theme color
Paragraph colorTest = section.AddParagraph();
TextRange textRange = colorTest.AppendText("Accent1 Color Test");
textRange.CharacterFormat.ThemeColor = ThemeColor.Accent1; // Use the Accent1 theme color directly
doc.SaveToFile(outputFile, FileFormat.Docx);
doc.Close();
|
| New Feature | SPIREDOC-11492 | Added support for copying the theme of an existing document to another.
// Load the source document and get its theme
Document sourceDoc = new Document();
sourceDoc.LoadFromFile("Theme.docx");
Theme sourceTheme = sourceDoc.Theme;
// Create a destination document
Document newDoc = new Document();
// Copy the source document's theme (theme fonts and colors) to the destination document
sourceDoc.CloneThemesTo(newDoc);
newDoc.SaveToFile("CopyTheme.docx", FileFormat.Docx);
|
| New Feature | SPIREDOC-11492 | Added support for retrieving and modifying document theme.
Document doc = new Document();
// Set the font faces of the document theme
doc.Theme.MinorFonts.Latin = "Algerian";
doc.Theme.MinorFonts.EastAsian = "Aharoni";
doc.Theme.MinorFonts.ComplexScript = "Andalus";
// Set the theme font and theme color of the style's character format
CharacterFormat font = ((ParagraphStyle)doc.Styles["Normal"]).CharacterFormat;
font.ThemeFont = ThemeFont.Minor;
font.ThemeColor = ThemeColor.Accent2;
// Get the theme font and theme color
ThemeFont themeFont = font.ThemeFont;
string fontName = font.FontName;
Color textColor = font.TextColor;
doc.SaveToFile("ThemeAttributes.docx", FileFormat.Docx);
|
| New Feature | SPIREDOC-11878 | Added support for the "embed only the characters used in the document" setting.
doc.setEmbedFontsInFile(true); doc.setSaveSubsetFonts(true); |
| New Feature | - | Added support for setting the fill format of charts and their data series.
// Create a document and add a column chart
Document doc = new Document();
Section section = doc.AddSection();
ShapeObject shape = section.AddParagraph().AppendChart(ChartType.Column, 500, 300);
Chart chart = shape.Chart;
chart.Series.Clear();
chart.Series.Add("Sales", new string[] { "Q1", "Q2", "Q3", "Q4" }, new double[] { 120, 90, 160, 200 });
// Chart area - solid fill
chart.Format.Fill.FillType = FillType.Solid;
chart.Format.Fill.Color = Color.OrangeRed;
chart.Format.Fill.Transparency = 0.3;
// Data points of the first series - linear gradient fill
Fill seriesFill = chart.Series[0].DataPoints.Format.Fill;
seriesFill.FillType = FillType.Shade;
seriesFill.GradientType = GradientFillType.Linear;
seriesFill.SetGradientDirection(GradientFillDirection.LinearUp);
seriesFill.GradientStops.Add(new GradientStop(0, Color.White));
seriesFill.GradientStops.Add(new GradientStop(1, Color.OrangeRed));
// Data labels - enable and use a solid fill
chart.Series[0].HasDataLabels = true;
chart.Series[0].DataLabels.Format.Fill.FillType = FillType.Solid;
chart.Series[0].DataLabels.Format.Fill.Color = Color.LightYellow;
doc.SaveToFile("ChartFill.docx", FileFormat.Docx);
// Create a document and add a line chart
Document doc = new Document();
Section section = doc.AddSection();
ShapeObject shape = section.AddParagraph().AppendChart(ChartType.Line, 500, 300);
Chart chart = shape.Chart;
chart.Series.Clear();
chart.Series.Add("Trend", new string[] { "Cat1", "Cat2", "Cat3", "Cat4" }, new double[] { 4.3, 2.4, 3.1, 5.2 });
// Chart area - border weight, dash style and solid color
chart.Format.Stroke.Weight = 2;
chart.Format.Stroke.DashStyle = DashStyle.Dash;
chart.Format.Stroke.Fill.FillType = FillType.Solid;
chart.Format.Stroke.Fill.Color = Color.Blue;
// Data series border - set through its data points
chart.Series[0].DataPoints.Format.Stroke.Fill.FillType = FillType.Solid;
chart.Series[0].DataPoints.Format.Stroke.Fill.Color = Color.Red;
chart.Series[0].DataPoints.Format.Stroke.Weight = 1.5;
// Start and end arrows on the axes
chart.AxisX.Format.Stroke.StartArrowType = ArrowType.Arrow;
chart.AxisX.Format.Stroke.EndArrowType = ArrowType.Arrow;
chart.AxisY.Format.Stroke.StartArrowType = ArrowType.Arrow;
chart.AxisY.Format.Stroke.EndArrowType = ArrowType.Arrow;
doc.SaveToFile("ChartStroke.docx", FileFormat.Docx);
|
| Bug Fix | SPIREDOC-12046 | Fixed the issue where extra pages were deleted when deleting pages in Word documents. |
| Bug Fix | SPIREDOC-12058 | Fixed the issue where some Symbol font characters were missing during Word to PDF conversion. |
Click the link below to download Spire.Doc 14.9.1:
More information of Spire.Doc new release or hotfix: