Dodaj efekt odbicia

Tworzenie tekstu z efektem odbicia

Efekt odbicia dodaje lustrzane odbicie pod tekstem, tworząc wypolerowany i nowoczesny wygląd. 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. Dla własnych odbić można dostosować właściwości takie jak odległość, rozmycie i przezroczystość, aby dokładnie dostroić wygląd.

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. Na koniec dodaj akapit do dokumentu, aby zastosować efekt odbicia.

Wyjaśnienie kodu

Utwórzmy nowy dokument WORD i dodajmy do niego tekst z efektem odbicia. 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. To odzwierciedla hierarchię dokumentu: Dokument → Akapit → Fragment tekstu → Zawartość tekstu. Na koniec dokument zostaje zapisany.

Zapoznaj się z samouczkami dotyczącymi elementów dokumentów w IronWord.

Gotowy, aby rozpocząć?
Nuget Pliki do pobrania 44,829 | Wersja: 2026.5 just released
Still Scrolling Icon

Wciąż przewijasz?

Czy chcesz szybko dowodu? PM > Install-Package IronWord
uruchom próbkę zobacz, jak twoje dane stają się dokumentem Word.