Verlaufseffekt hinzufügen

Anwenden von Farbverlaufseffekten auf Text

Der Gradienteneffekt in IronWord ermöglicht es, Text farbliche Übergänge darzustellen und so optisch ansprechende Designs zu erstellen. IronWord provides preset gradient options through the Gradient class, such as Gradient.DefaultGray, which can be assigned directly to the GradientEffect property of a TextEffect.

To apply a gradient, create a TextStyle object and configure its TextEffect property with a GradientEffect. The gradient can be set using predefined static instances from the Gradient class, which offer commonly used color schemes and transitions. Diese Voreinstellungen vereinfachen das Hinzufügen professionell aussehender Farbverläufe, ohne dass Farbstopps manuell konfiguriert werden müssen.

Once the style is configured, create a Run containing TextContent and assign the style to the run's Style property. Add the run to a paragraph using AddChild, then insert the paragraph into the document. Dieser strukturierte Ansatz gewährleistet, dass der Gradienteneffekt korrekt angewendet und im Ausgabedokument erhalten bleibt.

Code Erklärung

Der obige Code zeigt, wie man einen Verlaufs-Effekt auf Text anwendet. Zuerst wird ein neues Word-Dokument erstellt. Then, it creates a TextStyle object and configures it to use a gradient effect by assigning the Gradient.DefaultGray preset to the GradientEffect property.

To add the styled text, 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 gradient effect. The Run is added to the Paragraph using AddChild, and the Paragraph is added to the document. Dies folgt der Dokumenthierarchie: Dokument → Absatz → Textabschnitt → Textinhalt. Schließlich wird das neue Word-Dokument exportiert.

Für weitere Beispiele und Demonstrationen navigieren Sie bitte zu dem folgenden Artikel: So fügen Sie Text einen Verlaufs-Effekt hinzu.

Hier finden Sie weitere Tutorials zu Word-Dokumentelementen.

Bereit anzufangen?
Nuget Downloads 35,581 | Version: 2026.3 gerade veröffentlicht
Still Scrolling Icon

Scrollst du immer noch?

Sie brauchen schnell einen Beweis? PM > Install-Package IronWord
Führen Sie ein Beispiel aus und sehen Sie zu, wie aus Ihren Daten ein Word-Dokument wird.