Ajouter un effet de réflexion

Création de texte avec effet de réflexion

L'effet de réflexion ajoute une image miroir sous le texte, créant ainsi un aspect soigné et moderne. In IronWord, this effect is applied through the ReflectionEffect property of a TextEffect object, which can be customized or used with default settings.

To implement a reflection effect, create a TextStyle and configure its TextEffect property with a Reflection instance. The Reflection class supports default initialization, which applies standard reflection parameters suitable for most use cases. Pour les reflets personnalisés, des propriétés telles que la distance, le flou et la transparence peuvent être ajustées pour affiner l'apparence.

After defining the text style, create a Run containing your TextContent and assign the configured style to the run. Use AddChild to add the run to a paragraph, maintaining the proper document hierarchy of Document → Paragraph → Run → TextContent. Enfin, ajoutez le paragraphe au document pour appliquer l'effet de réflexion.

Explication du code

Créons un nouveau document Word et ajoutons-y du texte avec un effet de réflexion. Initially, a new WordDocument object named doc is created. A TextStyle object is then instantiated and configured to include a reflection effect by setting its TextEffect property to a new Reflection object.

To add the styled text with the reflection effect, a Paragraph is created, then a Run object is created containing TextContent with "Hello World". The TextStyle is assigned to the Run, applying the reflection 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, le document est enregistré.

Explorez les éléments de document dans 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.