Spire.Doc 13.4 のリリースを発表いたします。今回のアップデートでは、「グリッド定義時に右インデントを自動調整」機能と「フォントのカーニング」機能のサポートを追加するとともに、SmartArt グラフィックの追加・操作を行うための新規インターフェースを複数追加しました。さらに、Word 文書の処理に影響する 3 つの問題を修正しました。詳細は以下をご覧ください。
変更内容一覧
| カテゴリー | ID | 説明 |
| 新機能 | SPIREDOC-9870 | 「グリッド定義時に右インデントを自動調整」機能のサポートを追加しました。
paragraph.Format.AdjustRightIndent = true; // デフォルト値はtrue |
| 新機能 | SPIREDOC-11030 | 「フォントのカーニング」機能のサポートを追加しました。
textRange.CharacterFormat.Kerning = 2.5f; |
| 新機能 | SPIREDOC-10514 SPIREDOC-11494 | SmartArt グラフィックの追加・操作のための新規インターフェースを複数追加しました。
Document document = new Document();
Section section = document.AddSection();
Spire.Doc.Documents.Paragraph paragraph = section.AddParagraph(); paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center;
Spire.Doc.Fields.TextRange textRange = paragraph.AppendText("RepeatingBendingProcess");
textRange.CharacterFormat.FontSize = 28f;
textRange.CharacterFormat.FontName = "Times New Roman";
paragraph = section.AddParagraph();
paragraph = section.AddParagraph();
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center;
// 「繰り返しベンディングプロセス」レイアウトでSmartArtを追加
Spire.Doc.Fields.Shapes.Shape shape = paragraph.AppendSmartArt(SmartArtType.RepeatingBendingProcess, 432, 252);
SmartArt repeatingBendingSmartArt = shape.SmartArt;
// ノードテキストを追加
SmartArtNode process1 = repeatingBendingSmartArt.Nodes[0];
process1.Text = "1";
((Spire.Doc.Fields.TextRange)process1.Paragraphs[0].ChildObjects[0]).CharacterFormat.FontName = "Calibri";
((Spire.Doc.Fields.TextRange)process1.Paragraphs[0].ChildObjects[0]).CharacterFormat.FontSize = 20f;
((Spire.Doc.Fields.TextRange)process1.Paragraphs[0].ChildObjects[0]).CharacterFormat.TextColor = Color.Crimson;
// ノードテキストを追加
SmartArtNode process2 = repeatingBendingSmartArt.Nodes[1];
process2.Text = "2";
((Spire.Doc.Fields.TextRange)process2.Paragraphs[0].ChildObjects[0]).CharacterFormat.FontSize = 15f;
// ノードテキストを追加
SmartArtNode process3 = repeatingBendingSmartArt.Nodes[2];
process3.Text = "3";
((Spire.Doc.Fields.TextRange)process3.Paragraphs[0].ChildObjects[0]).CharacterFormat.FontSize = 10f;
// ノードテキストを追加
SmartArtNode process4 = repeatingBendingSmartArt.Nodes[3];
process4.Text = "4";
((Spire.Doc.Fields.TextRange)process4.Paragraphs[0].ChildObjects[0]).CharacterFormat.FontSize = 10f;
// ノードテキストを追加
SmartArtNode process5 = repeatingBendingSmartArt.Nodes[4];
process5.Text = "5";
((Spire.Doc.Fields.TextRange)process5.Paragraphs[0].ChildObjects[0]).CharacterFormat.FontSize = 10f;
document.SaveToFile(outputFile, FileFormat.Docx);
document.Close(); |
| 新機能 | SPIREDOC-11622 | SmartArt 内のすべてのノードからテキストを取得する機能のサポートを追加しました。
using (Document document = new Document(inputFile))
{
// すべてのセクションをループ処理
foreach (Section section in document.Sections)
{
if (section?.Paragraphs == null) continue;
// セクション内のすべての段落をループ処理
foreach (Spire.Doc.Documents.Paragraph paragraph in section.Paragraphs)
{
foreach (var childObj in paragraph.ChildObjects)
{
if (childObj is Spire.Doc.Fields.Shapes.Shape shape && shape.HasSmartArt)
{
SmartArt smartArt = shape.SmartArt;
if (smartArt == null) continue;
TraverseSmartArtNodes(smartArt.Nodes, builder, 0);
}
}
}
}
}
public static void TraverseSmartArtNodes(SmartArtNodeCollection nodes, StringBuilder builder, int level)
{
if (nodes == null || nodes.Count == 0) return;
for (int nodeIdx = 0; nodeIdx < nodes.Count; nodeIdx++)
{
SmartArtNode node = nodes[nodeIdx];
if (node == null) continue;
// ノードテキストをクリーンアップ
string nodeText = node.Text != null ? node.Text.Trim() : "Empty Text";
if (nodeText == "\r" || string.IsNullOrEmpty(nodeText)) continue;
// ノードレベルの識別子を連結
string nodePrefix;
switch (level)
{
case 0:
nodePrefix = "smartArt.Nodes";
break;
case 1:
nodePrefix = "smartArt.Nodes.ChildNodes";
break;
case 2:
nodePrefix = "smartArt.Nodes.ChildNodes.ChildNodes";
break;
default:
nodePrefix = $"smartArt.Nodes.Level{level}";
break;
}
// 基本的なテキスト出力
builder.AppendLine($"{nodePrefix}_{nodeIdx}: {nodeText}");
// 子ノードを再帰的に処理
TraverseSmartArtNodes(node.ChildNodes, builder, level + 1);
}
} |
| 不具合修正 | SPIREDOC-11724 | 段落テキストの取得結果が不正確になる問題を修正しました。 |
| 不具合修正 | SPIREDOC-11743 | Word ファイルを PDF に変換する際にアラビア語テキストのフォントが変更される問題を修正しました。 |
| 不具合修正 | SPIREDOC-11787 | ページ抽出時に不要な空白ページが表示される問題を修正しました。 |
Spire.Doc 14.3 をダウンロードするには、以下のリンクをクリックしてください:






