C#でPDFの印刷設定を構成する方法 | IronPrint

How to Add Gradient Effect to Text

This article was translated from English: Does it need improvement?
Translated
View the article in English

テキストにグラデーション効果を適用することは、一色から別の色、または複数の色にわたって滑らかに色が変化する効果を、文字または背景に適用することを意味します。 この効果はテキストに深み、視覚的な興味、そして動的な外観を加え、目立たせその美的外観を高めます。 グラデーション効果は、線形(色が直線上で変化)または放射状(色が中央から外側に向かって変化)です。

クイックスタート:IronWordを使用してテキストにグラデーション効果を追加する

以下に、IronWordを使用してテキストに組み込みのグラデーション効果を数行で適用する方法を示す簡単な例を紹介します - 素早く始めたい方や瞬時に視覚的な結果を確認したい方にぴったりです。

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronWord with NuGet Package Manager

    PM > Install-Package IronWord

  2. Copy and run this code snippet.

    var doc = new IronWord.WordDocument();
    doc.AddText("Test").Style = new IronWord.Models.TextStyle(){ TextEffect = new IronWord.Models.TextEffect(){ GradientEffect = IronWord.Models.Gradient.DefaultGray } };
    doc.SaveAs("out.docx");
  3. Deploy to test on your live environment

    Start using IronWord in your project today with a free trial
    arrow pointer
class="hsg-featured-snippet">

最小ワークフロ (5 ステップ)

  1. テキストにグラデーションを追加できる C# ライブラリをダウンロードします。
  2. 新規作成されたテキストまたは既存のテキストにテキスト効果を適用します。
  3. Gradient クラスの静的な名前付きインスタンスを使用してプリセットのグラデーション効果を使用します。
  4. GradientEffect プロパティを構成し、テキストのアウトラインをカスタマイズします。
  5. 編集された Word ドキュメントを新しいファイルとしてエクスポートします。

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

テキストのグラデーション効果を指定するために、TextStyle オブジェクトを作成し、Gradient オブジェクトで GradientEffect プロパティを埋めます。 最後に、TextStyle オブジェクトを TextEffect プロパティに割り当てることで、新しいスタイルのテキストを追加します。

:path=/static-assets/word/content-code-examples/how-to/text-effect-gradient-effect.cs
using IronWord;
using IronWord.Models;

// Create new Word document
WordDocument doc = new WordDocument();

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    GradientEffect = Gradient.DefaultGray,
};

// Add text with style
doc.AddText("Hello World").Style = textStyle;

// Export new Word document
doc.SaveAs("gradientEffect.docx");
Imports IronWord
Imports IronWord.Models

' Create new Word document
Private doc As New WordDocument()

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {.GradientEffect = Gradient.DefaultGray}

' Add text with style
doc.AddText("Hello World").Style = textStyle

' Export new Word document
doc.SaveAs("gradientEffect.docx")
$vbLabelText   $csharpLabel
class="content-img-align-center">
class="center-image-wrapper"> Add gradient effect

グラデーション効果のプロパティ

グラデーション効果は、多様なデザイン要求を満たすために調整可能な属性の範囲を提供します。 各プロパティの詳細な説明は以下のリストを参照してください:

GradientStop

  • Color: グラデーション ストップのカラースキームを取得または設定します。
  • StopPoint: グラデーション ストップの位置を取得または設定します。

グラデーションストップは、特定の色が定義されるグラデーション内のポイントです。

Gradient

  • StopPoints: グラデーション塗りつぶしを定義するグラデーションストップのリストを取得または設定します。
  • LinearShadeScaled: 線形シェードがスケーリングされているかどうかを示す値を取得または設定します。
  • LinearShadeAngle: 線形シェードの角度を取得または設定します。
:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-gradient-effect.cs
using IronWord;
using IronWord.Models;
using System.Collections.Generic;

// Create new Word document
WordDocument doc = new WordDocument();

// Create gradient stops
GradientStop firstGradientStop = new GradientStop()
{
    Color = IronWord.Models.Color.Aqua,
    StopPoint = 1
};
GradientStop secondGradientStop = new GradientStop()
{
    Color = IronWord.Models.Color.OrangeRed,
    StopPoint = 10
};

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    GradientEffect = new Gradient()
    {
        StopPoints = new List<GradientStop> { firstGradientStop, secondGradientStop },
        LinearShadeAngle = 45,
        LinearShadeScaled = true,
    }
};

// Add text with style
doc.AddText("Hello World").Style = textStyle;

// Export new Word document
doc.SaveAs("customizedGradientEffect.docx");
Imports IronWord
Imports IronWord.Models
Imports System.Collections.Generic

' Create new Word document
Private doc As New WordDocument()

' Create gradient stops
Private firstGradientStop As New GradientStop() With {
	.Color = IronWord.Models.Color.Aqua,
	.StopPoint = 1
}
Private secondGradientStop As New GradientStop() With {
	.Color = IronWord.Models.Color.OrangeRed,
	.StopPoint = 10
}

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {
	.GradientEffect = New Gradient() With {
		.StopPoints = New List(Of GradientStop) From {firstGradientStop, secondGradientStop},
		.LinearShadeAngle = 45, .LinearShadeScaled = True
	}
}

' Add text with style
doc.AddText("Hello World").Style = textStyle

' Export new Word document
doc.SaveAs("customizedGradientEffect.docx")
$vbLabelText   $csharpLabel
class="content-img-align-center">
class="center-image-wrapper"> Customized gradient effect

よくある質問

C# を使用して Word ドキュメントのテキストにグラデーション効果を追加するにはどうすればよいですか?

IronWord の C# ライブラリを使用して Word ドキュメントにグラデーション効果を追加できます。まずライブラリをダウンロードし、新しいテキストまたは既存のテキストにテキスト効果を適用します。Gradient クラスの静的名前付きインスタンスを介してプリセット グラデーション効果を使用し、GradientEffect プロパティを構成することによってカスタマイズします。

IronWord を使用してグラデーション効果を適用する手順は何ですか?

IronWord を使用してグラデーション効果を適用するには、次の手順に従います: C# ライブラリをダウンロードし、テキストにグラデーションを適用し、Gradient クラスのプリセット グラデーション効果を使用し、GradientEffect プロパティを構成し、最後に編集されたドキュメントをエクスポートします。

IronWord でグラデーション効果を持つ TextStyle オブジェクトを作成するにはどうすればよいですか?

IronWord では、TextStyle オブジェクトを作成し、GradientEffect プロパティに Gradient オブジェクトを設定します。この TextStyleTextEffect プロパティに割り当てて、テキストに適用します。

IronWord におけるグラデーション ストップの目的は何ですか?

IronWord のグラデーション ストップは、特定の色が定義されるグラデーション内のポイントです。それらは、GradientStop クラスを使用して制御され、Color (カラースキーム) や StopPoint (グラデーション ストップの位置) などのプロパティを含みます。

IronWord でグラデーション ストップをカスタマイズできますか?

はい、特定の色と位置を持つ GradientStop オブジェクトを Gradient オブジェクトの StopPoints リストに追加することにより、IronWord でグラデーション ストップをカスタマイズできます。これにより、パーソナライズされたグラデーション効果が得られます。

IronWord の Gradient クラスの主要プロパティは何ですか?

IronWord の Gradient クラスには、グラデーション ストップを定義する StopPoints、線形シェードがスケールされているかどうかを示す LinearShadeScaled、および線形シェードの角度を設定する LinearShadeAngle などの主要プロパティが含まれます。

IronWord を使用してグラデーション効果を追加した後、Word ドキュメントをどのようにエクスポートしますか?

IronWord を使用してテキストにグラデーション効果を追加した後、適用したグラデーション効果を含む新しい形式でファイルを保存することで、編集された Word ドキュメントをエクスポートできます。

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はいいですか?
Nuget ダウンロード 25,807 | バージョン: 2025.11 ただ今リリースされました