テキストにシャドウ効果を追加する方法

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

テキストのシャドウ効果は、テキスト要素に深みと区別を作成するために使用されるビジュアルエンハンスメントのテクニックです。 適用すると、元のテキストの後ろに複製されたテキストが表示され、影のように見えるように少しオフセットされる。 シャドウとして知られるこの二次テキストは、さまざまな視覚効果を得るためにいくつかの方法で調整することができる。

 用 C# NuGet ライブラリ

でインストール NuGet

Install-Package IronWord
 用 C# NuGet ライブラリ

でインストール NuGet

Install-Package IronWord
または
Java PDF JAR(ジャバPDF JAR)

ダウンロード DLL (ディーエルエル)

DLLをダウンロード

プロジェクトに手動でインストールする

今日からプロジェクトでIronPDFを使い始めましょう。無料のトライアルをお試しください。

最初のステップ:
green arrow pointer

チェックアウト IronWord オン Nuget 迅速なインストールと展開のために。8百万以上のダウンロード数により、をC#で変革しています。

 用 C# NuGet ライブラリ nuget.org/packages/IronWord/
Install-Package IronWord

シャドー効果の追加

テキストのシャドウ効果を指定するには、TextStyle オブジェクトを作成し、ShadowEffect プロパティに Shadow オブジェクトを設定します。 最後に、TextEffectプロパティにTextStyleオブジェクトを代入して、スタイルを持つ新しいテキストを追加します。

:path=/static-assets/word/content-code-examples/how-to/text-effect-shadow-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()
{
    ShadowEffect = Shadow.OuterShadow1,
};

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

// Export new Word document
doc.SaveAs("shadowEffect.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 {.ShadowEffect = Shadow.OuterShadow1}

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

' Export new Word document
doc.SaveAs("shadowEffect.docx")
VB   C#
影の効果を加える

シャドウ効果のプロパティ

定義済みのシャドウ値を割り当てるだけでなく、シャドウ効果のすべてのプロパティを設定できます。 これにより、シャドウ効果を自由自在にカスタマイズできる。 以下の物件とその説明をご覧ください:

  • Alignment:シャドウのアライメントを取得または設定します。
  • BlurRadius:シャドウ効果のぼかし半径を取得または設定します。 ぼかしの半径をポイントで指定します。 (1/72インチ).
  • DirectionAngle:影エフェクトの方向角度を取得または設定します。 方向角度は度単位で指定する。
  • DistanceFromText:テキストまたはオブジェクトからのシャドウ効果の距離を取得または設定します。 距離はポイントで指定する。 (1/72インチ).
  • HorizontalScalingFactor:シャドウ効果の水平スケーリング係数を取得または設定します。
  • HorizontalSkewAngle:シャドウ効果の水平スキュー角度を取得または設定します。 スキュー角は度単位で指定する。
  • SchemeColor:シャドウ効果のスキームカラーを取得または設定します。
  • VerticalScalingFactor:シャドウ効果の垂直方向のスケーリング係数を取得または設定します。

  • VerticalSkewAngle:シャドウ効果の垂直方向のスキュー角度を取得または設定します。 スキュー角は度単位で指定する。
:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-shadow-effect.cs
using IronWord;
using IronWord.Models;
using IronWord.Models.Enums;

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

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    ShadowEffect = new Shadow()
    {
        Alignment = RectangleAlignmentValues.BottomLeft,
        BlurRadius = 5,
        DirectionAngle = 45,
        DistanceFromText = 3,
        HorizontalScalingFactor = 100,
        VerticalScalingFactor = 100,
        HorizontalSkewAngle = 0,
        SchemeColor = IronWord.Models.Color.Aqua,
        VerticalSkewAngle = 0,
    },
};

// Add text with style
doc.AddText("Customized shadow").Style = textStyle;

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

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

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {
	.ShadowEffect = New Shadow() With {
		.Alignment = RectangleAlignmentValues.BottomLeft,
		.BlurRadius = 5,
		.DirectionAngle = 45,
		.DistanceFromText = 3,
		.HorizontalScalingFactor = 100,
		.VerticalScalingFactor = 100,
		.HorizontalSkewAngle = 0,
		.SchemeColor = IronWord.Models.Color.Aqua,
		.VerticalSkewAngle = 0
	}
}

' Add text with style
doc.AddText("Customized shadow").Style = textStyle

' Export new Word document
doc.SaveAs("customizedShadowEffect.docx")
VB   C#
シャドー効果のカスタマイズ