Agregar efecto de degradado

Cómo aplicar efectos de degradado al texto

El efecto degradado en IronWord permite que el texto muestre transiciones de color, creando diseños visualmente atractivos. 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. Estos ajustes preestablecidos simplifican el proceso de agregar degradados de aspecto profesional sin tener que configurar manualmente las paradas de color.

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. Este enfoque estructurado garantiza que el efecto de degradado se aplique y conserve correctamente en el documento de salida.

Explicación del código

El código anterior demuestra cómo aplicar un efecto degradado al texto. Primero, crea un nuevo documento de Word. 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. Esto sigue la jerarquía del documento: Documento → Párrafo → Ejecutar → Contenido de texto. Finalmente, se exporta el nuevo documento de Word.

Para más ejemplos y demostraciones, por favor navegue al siguiente artículo: Cómo Añadir Efecto Degradado al Texto.

Explora más tutoriales sobre elementos de documentos de Word aquí

¿Listo para empezar?
Nuget Descargas 36,374 | Versión: 2026.3 recién lanzado
Still Scrolling Icon

¿Aún desplazándote?

¿Quieres una prueba rápida? PM > Install-Package IronWord
ejecuta una muestra observa cómo tus datos se convierten en un documento de Word.