Cómo Añadir un Efecto de Contorno de Texto al Texto en C# | IronWord

How to Add Text Outline Effect to Text

This article was translated from English: Does it need improvement?
Translated
View the article in English

A text outline effect adds a visible border around the characters of text, creating a defined outline that enhances readability or visual impact. This effect can be customized in terms of color, thickness, and style to suit design preferences. It's commonly used in graphics, typography, and digital design to make text stand out against backgrounds or to create a stylized appearance.

Quickstart: Apply a Default Text Outline Effect Instantly

With just one line, create a TextStyle that applies a ready-made text outline via TextOutlineEffect.DefaultEffect. It’s a fast way to let developers use IronWord to make text stand out without complex setup.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronWord with NuGet Package Manager

    PM > Install-Package IronWord

  2. Copy and run this code snippet.

    new IronWord.Models.TextStyle { TextEffect = new IronWord.Models.TextEffect { TextOutlineEffect = IronWord.Models.TextOutlineEffect.DefaultEffect } }
  3. Deploy to test on your live environment

    Start using IronWord in your project today with a free trial
    arrow pointer

Add Text Outline Effect

To specify the text outline effect for the text, create the TextStyle object and populate the TextOutlineEffect property with a TextOutlineEffect object. Finally, add new text with the style by assigning the TextStyle object to the TextEffect property.

:path=/static-assets/word/content-code-examples/how-to/text-effect-text-outline-effect.cs
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,
};

// Add text with style
doc.AddText("Hello World").Style = textStyle;

// Export new Word document
doc.SaveAs("textOutlineEffect.docx");
Imports IronWord
Imports IronWord.Models

' Create new Word document
Private doc As New WordDocument()

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {.TextOutlineEffect = TextOutlineEffect.DefaultEffect}

' Add text with style
doc.AddText("Hello World").Style = textStyle

' Export new Word document
doc.SaveAs("textOutlineEffect.docx")
$vbLabelText   $csharpLabel
Add text outline effect

Text Outline Effect Properties

The text outline effect offers a variety of customizable properties to suit any design need. Below are the properties along with their descriptions:

  • PenAlignment: Gets or sets the alignment of the pen used for the outline effect.
  • LineCapType: Gets or sets the type of line cap used for the outline effect.
  • LineWidth: Gets or sets the width of the outline effect line. Note: The width is specified in points (1/72 inch).
  • CompoundLineType: Gets or sets the type of compound line used for the outline effect.
  • LineJoin: Gets or sets the stroke join style used for the outline effect.
  • Color: Gets or sets the solid fill color for the outline effect.
  • PresetLineDash: Gets or sets the preset line dash style for the outline effect.
:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-text-outline-effect.cs
using IronWord;
using IronWord.Models;
using IronWord.Models.Enums;

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

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    TextOutlineEffect = new TextOutlineEffect()
    {
        Color = IronWord.Models.Color.Red,
        CompoundLineType = CompoundLineValues.Double,
        LineCapType = LineCapValues.Round,
        LineJoin = StrokeJoinStyleValues.Bevel,
        LineWidth = 0.3,
        PenAlignment = PenAlignmentValues.Center,
        presetLineDash = PresetLineDashValues.Solid
    },
};

// Add text with style
doc.AddText("Customized text outline").Style = textStyle;

// Export new Word document
doc.SaveAs("customizedTextOutlineEffect.docx");
Imports IronWord
Imports IronWord.Models
Imports IronWord.Models.Enums

' Create new Word document
Private doc As New WordDocument()

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {
	.TextOutlineEffect = New TextOutlineEffect() With {
		.Color = IronWord.Models.Color.Red,
		.CompoundLineType = CompoundLineValues.Double,
		.LineCapType = LineCapValues.Round,
		.LineJoin = StrokeJoinStyleValues.Bevel,
		.LineWidth = 0.3,
		.PenAlignment = PenAlignmentValues.Center,
		.presetLineDash = PresetLineDashValues.Solid
	}
}

' Add text with style
doc.AddText("Customized text outline").Style = textStyle

' Export new Word document
doc.SaveAs("customizedTextOutlineEffect.docx")
$vbLabelText   $csharpLabel
Customized text outline effect

Preguntas Frecuentes

¿Qué es un efecto de contorno de texto en un documento de Word?

Un efecto de contorno de texto en un documento de Word agrega un borde visible alrededor de los caracteres de texto, mejorando su legibilidad e impacto visual. Este efecto es personalizable en términos de color, grosor y estilo para adaptarse mejor a las preferencias de diseño.

¿Cómo puedo aplicar un efecto de contorno de texto en C#?

En C#, puedes aplicar un efecto de contorno de texto usando la clase TextOutlineEffect en IronWord. Puedes configurar sus propiedades como color, ancho de línea y estilo para personalizar el efecto para tu texto.

¿Cuáles son los pasos para agregar un efecto de contorno de texto usando IronWord?

Los pasos incluyen descargar la biblioteca IronWord, aplicar el efecto de texto a texto nuevo o existente, configurar las propiedades de TextOutlineEffect y exportar el documento editado como un nuevo archivo.

¿Puedo personalizar las propiedades de un efecto de contorno de texto en C#?

Sí, puedes personalizar el efecto de contorno de texto ajustando propiedades como PenAlignment, LineCapType, LineWidth, CompoundLineType, LineJoin, Color y PresetLineDash usando IronWord.

¿Cuál es la unidad de medida para el ancho de línea en un efecto de contorno de texto?

El ancho de línea de un efecto de contorno de texto se mide en puntos, donde un punto equivale a 1/72 de una pulgada.

¿Cómo exporto un documento de Word después de aplicar un efecto de contorno de texto?

Después de aplicar un efecto de contorno de texto en IronWord, puedes exportar el documento de Word editado usando las funciones de exportación de la biblioteca para guardar tus cambios como un nuevo archivo.

¿Cuál es el propósito de usar efectos de contorno de texto en el diseño?

Los efectos de contorno de texto se usan para hacer que el texto sobresalga sobre los fondos o para crear una apariencia estilizada, mejorando la legibilidad y el impacto visual en el diseño digital.

¿Cómo defino un estilo de texto con un efecto de contorno de texto en C#?

Puedes definir un estilo de texto creando un objeto TextStyle y llenando su propiedad TextOutlineEffect con un objeto TextOutlineEffect. Asigna este estilo a tu texto a través de la propiedad TextEffect.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Nuget Descargas 25,807 | Versión: 2025.11 recién lanzado