Add Text Outline

Adding Text Outline Effects

Text outline effects enhance text visibility and style by drawing a border around each character. This effect is particularly useful for creating bold, eye-catching text or ensuring readability when text appears over images or colored backgrounds. 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. This preset provides a standard outline configuration that works well for most scenarios. For custom outlines, developers can specify properties like outline width, color, and line style to achieve specific visual effects.

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. This structured approach ensures proper formatting and maintains document integrity.

Code Explanation

Applying a text outline to text is super simple with IronWord. Despite its simplicity, each attribute of the text outline can be adjusted to suit every need. 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. This follows the document hierarchy: Document → Paragraph → Run → TextContent. Finally, the document is exported.

Learn more about Document Elements with IronWord.

Ready to Get Started?
Nuget Downloads 33,665 | Version: 2026.3 just released