23
Views
3
Comments
HTML Text with MSWordsUtil

Is there a way to generate a Word document (.docx) in OutSystems using an HTML string as input? I have tried MSWordsUtil but it looks like the best I can do is manually assigning the format. Below example is input where receive from CKEditor.

For example, given the following HTML:


<p> This is a normal <u>paragraph</u> with <strong>important text</strong> </p>


I’d like to convert it into a Word document that keeps the formatting (underline, bold, etc.).

What would be the best approach to achieve this?

2024-10-09 04-44-30
Bhanu Pratap

Generating a .docx from HTML (e.g., CKEditor output with bold/underline) using MSWordsUtil requires manual formatting, which is cumbersome.

Solution: Use the CreateDocxFromHtml Forge component to directly convert HTML to .docx, preserving basic formatting. Input HTML source and file path; it generates the file server-side for download.

Reference: https://www.outsystems.com/forge/component-overview/2366/createdocxfromhtml

Alternative: HTML2Word Forge component for similar HTML-to-.docx conversion.

Reference: https://www.outsystems.com/forge/component-overview/12008/html2word-o11

For client-side option: HTML To MS Word Converter (modify script for .docx output as per forum discussion).

Reference: https://www.outsystems.com/forge/component-overview/8692/html-to-ms-word-converter-o11 and https://www.outsystems.com/forums/discussion/84198/html-to-ms-word-converter-doc-to-docx-conversion/

2024-02-16 11-58-28
Sheikh Mohd Fahad

Hey @Muhammad Faiq Roslan,


You can go with the solution proposed by Bhanu Pratap in the above comment.

Or else, there’s another workaround: convert the HTML to PDF first, and then convert the PDF to a Word document. You can easily find Forge components for both steps, and this approach is relatively simple to implement. 

Choose what suits you best!

I hope this will help you.

2026-03-20 01-28-51
Saugat Biswas

Hi @Muhammad Faiq Roslan,

OutSystems doesn’t have a native, out‑of‑the‑box way to convert rich HTML into a .docx while preserving formatting. 

And MSWordUtil is intentionally low‑level and requires you to build the document structure manually, so it won’t parse HTML for you.

Solutions:

Option 1: .NET Extension using OpenXML + HtmlToOpenXml (Recommended when accuracy matters)

  • Create a .NET Extension in Integration Studio 
  • Use: 
    • DocumentFormat.OpenXml 
    • HtmlToOpenXml (popular open‑source library) 
  • Feed it your HTML string 
  • Output a .docx binary back to OutSystems

This works wonders because:

  • Preserves formatting (bold, underline, headings, lists, tables
  • Handles CKEditor HTML well
  • Produces real Word documents
  • No external services needed

Option 2: External API (Microservice or SaaS)

Best for ODC or low maintenance 

Examples 

  • Cloud APIs that accept HTML and return DOCX 
  • Internal microservice built in .NET / Node 

Trade‑offs 

  • No OutSystems extension maintenance 
  • Works in ODC
  • If using external APIs (outside organization), data security could be a challenge.

Hope this helps.

Cheers,

Saugat

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.