Spire.Doc 14.9.1 のリリースをお知らせいたします。本バージョンでは Word 文書のテーマ管理機能が大幅に強化され、図表のスタイル設定や文書出力時のフォント埋め込み制御も拡充されました。
開発者はプログラムから Word テーマの作成・複製・編集を自由に実行し、複数ファイルのデザインを統一できます。
また、ページ削除処理とファイル変換に関する重大な不具合が 2 件修正され、文書処理全体の安定性が向上しています。詳細は下記の通りです。
変更内容一覧
| カテゴリー | ID | 説明 |
| 新機能 | SPIREDOC-11492 | カスタム文書テーマの作成に対応。
// 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();
|
| 新機能 | SPIREDOC-11492 | 既存文書のテーマを別の文書へコピーする機能を追加。
// 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);
|
| 新機能 | SPIREDOC-11492 | 文書テーマの取得・変更に対応。
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);
|
| 新機能 | SPIREDOC-11878 | 「文書内で使用される文字のみ埋め込む」設定に対応。
doc.setEmbedFontsInFile(true); doc.setSaveSubsetFonts(true); |
| 新機能 | — | 図表と図表データ系列の塗りつぶし書式設定機能を追加棒グラフ塗りつぶしサンプルコード。
// 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);
|
| 不具合修正 | SPIREDOC-12046 | Word文書のページ削除時、意図せず余分なページが削除される問題を修正。 |
| 不具合修正 | SPIREDOC-12058 | WordをPDFに変換する際、一部のSymbolフォント文字が欠落する問題を修正。 |
Spire.Doc 14.9.1 のダウンロードはこちらをクリック:






