Añadir Contorno de Texto
using IronWord;
using IronWord.Models;

// Create new Word document
WordDocument doc = new WordDocument();

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    TextOutlineEffect = TextOutlineEffect.DefaultEffect,
};

// Create paragraph
Paragraph paragraph = new Paragraph();

// Create run with text and style
Run textRun = new Run(new TextContent("Hello World"));
textRun.Style = textStyle;

// Add run to paragraph
paragraph.AddChild(textRun);

// Add paragraph to document
doc.AddParagraph(paragraph);

// Export new Word document
doc.SaveAs("textOutlineEffect.docx");
NuGet Download
PM > Install-Package IronWord
Añadir Contorno de Texto

Añadir Contorno de Texto

Agregar efectos de contorno de texto

Los efectos de contorno de texto mejoran la visibilidad y el estilo del texto al dibujar un borde alrededor de cada carácter. Este efecto es particularmente útil para crear texto llamativo y en negrita o para garantizar la legibilidad cuando el texto aparece sobre imágenes o fondos de colores. IronWord provides the TextOutlineEffect class with preset configurations for quick implementation.

To apply a text outline, create a TextStyle object and configure its TextEffect property with TextOutlineEffect.DefaultEffect. Este ajuste preestablecido proporciona una configuración de esquema estándar que funciona bien para la mayoría de los escenarios. Para los contornos personalizados, los desarrolladores pueden especificar propiedades como el ancho del contorno, el color y el estilo de línea para lograr efectos visuales específicos.

After setting up the text style, create a Run containing the desired TextContent and assign the configured style to the run's Style property. Use AddChild to add the styled run to a paragraph, then add the paragraph to the document. Este enfoque estructurado garantiza un formato adecuado y mantiene la integridad del documento.

Explicación del código

Aplicar un contorno de texto al texto es muy sencillo con IronWord. A pesar de su simplicidad, cada atributo del contorno de texto se puede ajustar para adaptarse a cada necesidad. Once a Word document is imported, the textStyle is configured to include a text outline effect by assigning TextOutlineEffect.DefaultEffect to the TextOutlineEffect property of a new TextEffect instance.

To apply this effect to text, a Paragraph is created, then a Run object is created containing the desired TextContent. The configured textStyle is assigned to the Run, applying the text outline 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, el documento se exporta.

Obtenga más información sobre los elementos del documento con IronWord.
Ver en GitHub

¿Listo para empezar?

Nuget Downloads 61,140Versión:2026.11recién lanzado