Html to OpenXmlHtml to OpenXml
Home
API Reference
LLM Docs Friendly
NuGet
GitHub
Home
API Reference
LLM Docs Friendly
NuGet
  • API Reference

    • Quickstart
    • Library Entry Points
    • Hyperlinks and Internal Navigation
    • Image and Asset Processing Guide
    • Styling
    • Tables
    • Numbering List
    • Preformated Text
    • Defined Terms and Notes
    • Page Layout
    • Right to Left (Rtl)
  • LLM Docs Friendly
  • Performance
  • Appendix

    • Content Type MIME Header
    • Convert .dotx to .docx
    • Placeholder Replacement
    • Restrict Editing
  • Changelog

The <pre> tag preserves all source formatting (whitespace, indentation, and line breaks) into the final DOCX document. This feature guarantees that your input text—such as code snippets, logs, or ASCII art—retains its exact visual structure.

Controlling Output Structure

The RenderPreAsTable property determines how the preserved content is physically packaged within the Word document:

  • Default (true): The content is placed inside a single-cell table. This is generally recommended when preserving complex arrangements or maintaining strict column alignments is desired.

  • Disabled (false): The content is placed inside a standard paragraph block. Use this when the simpler OpenXml structure is preferred, but you still need reliable line break and whitespace preservation.

// Default behavior (table embedding):
converter.RenderPreAsTable = true;

// Alternative structure (pure paragraph block):
converter.RenderPreAsTable = false; 

Text with preserved formatting

Edit this page
Last Updated: 10/12/26, 10:33 AM
Contributors: Olivier Nizet
Prev
Numbering List
Next
Defined Terms and Notes