グラデーション効果を追加

テキストにグラデーション効果を適用する

IronWordのグラデーション効果により、テキストの色の変化を表示でき、視覚的に魅力的なデザインを作成できます。 IronWord provides preset gradient options through the Gradient class, such as Gradient.DefaultGray, which can be assigned directly to the GradientEffect property of a TextEffect.

To apply a gradient, create a TextStyle object and configure its TextEffect property with a GradientEffect. The gradient can be set using predefined static instances from the Gradient class, which offer commonly used color schemes and transitions. これらのプリセットを使用すると、カラーストップを手動で設定することなく、プロフェッショナルなグラデーションを追加するプロセスが簡素化されます。

Once the style is configured, create a Run containing TextContent and assign the style to the run's Style property. Add the run to a paragraph using AddChild, then insert the paragraph into the document. この構造化されたアプローチにより、グラデーション効果が適切に適用され、出力ドキュメントに保持されます。

コードの説明

上記のコードは、テキストにグラデーションエフェクトを適用する方法を示しています。 まず、新しいWord文書を作成します。 Then, it creates a TextStyle object and configures it to use a gradient effect by assigning the Gradient.DefaultGray preset to the GradientEffect property.

To add the styled text, a Paragraph is created, then a Run object is created containing TextContent with "Hello World". The configured TextStyle is assigned to the Run, applying the gradient effect. The Run is added to the Paragraph using AddChild, and the Paragraph is added to the document. これは、ドキュメント階層に従います: ドキュメント → 段落 → 実行 → TextContent。 最後に、新しいWord文書がエクスポートされます。

より多くの例とデモンストレーションについては、次の記事に移動してください: テキストにグラデーション効果を追加する方法

Word文書の要素に関するその他のチュートリアルはこちらをご覧ください

準備はできましたか?
Nuget ダウンロード 36,374 | バージョン: 2026.3 リリース
Still Scrolling Icon

まだスクロールしていますか?

すぐに証拠が欲しいですか? PM > Install-Package IronWord
サンプルを実行する あなたのデータが Word ドキュメントになるのを見る。