Ajouter un effet d'ombre

Mise en œuvre d'effets d'ombre sur le texte

Les effets d'ombre ajoutent de la profondeur et du relief au texte en créant une ombre décalée derrière les caractères. IronWord provides predefined shadow presets through the Shadow class, offering various shadow styles that can be applied quickly without manual configuration.

To add a shadow effect, create a TextStyle and configure its TextEffect property with a shadow preset such as Shadow.OuterShadow1. These static named instances from the Shadow class provide professionally designed shadow configurations with appropriate blur, distance, and angle settings. Les variantes d'ombre extérieure projettent l'ombre loin du texte, créant ainsi un effet de relief.

Once the text style is configured with the desired shadow effect, create a Run object containing TextContent and assign the style to the run. Add the styled run to a paragraph using AddChild, then include the paragraph in the document. Cette approche respecte la hiérarchie des documents d'IronWord et garantit que l'effet d'ombre est correctement appliqué au fichier de sortie.

Explication du code

Il est possible d'ajouter un effet d'ombre à du texte dans un document Word en quelques lignes de code seulement. For completeness, let's first initialize a new WordDocument instance called doc. Then, a TextStyle object is created and configured to incorporate a shadow effect by assigning the Shadow.OuterShadow1 static named instance to the TextEffect property.

To add the styled text with the shadow effect, 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 shadow effect. The Run is added to the Paragraph using AddChild, and the Paragraph is added to the document. Cela suit la hiérarchie du document : Document → Paragraphe → Run → TextContent. Enfin, exportez le document Word.

Pour plus d'exemples et de démonstrations, veuillez consulter l'article suivant : Comment ajouter un effet d'ombre au texte

Explorez les éléments de document avec les tutoriels IronWord.

Prêt à commencer?
Nuget Téléchargements 35,581 | Version : 2026.3 vient de sortir
Still Scrolling Icon

Vous faites encore défiler ?

Vous voulez une preuve rapidement ? PM > Install-Package IronWord
exécuter un échantillon regarder vos données devenir un document Word.