Import & Export
Import and export Word documents to and from text, Markdown, and HTML formats
Convert Word documents to and from text, Markdown, and HTML formats.
Importing Content
From Plain Text
Split paragraphs on double newlines:
text = "Line one\n\nLine two\n\nLine three"
// Via BIF argument
word( text=text ).save( "from-text.docx" )
// Via instance method (appends to existing document)
word( "template.docx" )
.fromText( text )
.save( "appended.docx" )From Markdown
Uses CommonMark parsing — supports headings, paragraphs, lists, code blocks, blockquotes, links, and thematic breaks:
markdown = "
## Introduction
This is a paragraph with **bold** and *italic* text.
- Item 1
- Item 2
- Item 3
> A blockquote
`inline code`
"
// Via BIF argument
word( markdown=markdown ).save( "from-markdown.docx" )
// Via instance method
word().fromMarkdown( markdown ).save( "from-markdown.docx" )From HTML
Uses Jsoup parsing — supports headings, paragraphs, lists, tables, images, links, and basic formatting:
Supported HTML Elements
<h1>–<h6>
Heading (level 1–6)
<p>
Paragraph
<br>
New line
<b>, <strong>
Bold text
<i>, <em>
Italic text
<ul>
Unordered (bulleted) list
<ol>
Ordered (numbered) list
<li>
List item (supports nesting)
<table>, <tr>, <td>, <th>
Table
<a href="...">
Hyperlink
<img src="...">
Image (base64 data URIs supported)
<pre>, <code>
Monospace paragraph
<blockquote>
Indented, italic paragraph
<hr>
Page break
Exporting Content
To Plain Text
Extracts all visible text including tables (tab-separated), headers, and footers:
Output example:
To Markdown
Converts to Markdown with:
YAML front matter (title, author, subject from document properties)
#headings with proper levelPipe-delimited tables
**bold**/*italic*formattingBase64-embedded images
Blockquoted headers and footers
Output example:
To HTML
Converts to a full HTML document with:
Semantic heading tags (
<h1>–<h6>)Standard
<table>structure with<thead>/<tbody>Inline styles for bold, italic, color, size, and font family
Base64-embedded images
<footer>elements for headers and footers
Output example:
Format Conversion Pipeline
Chain import and export for format conversion:
Fidelity Notes
Word → Text
Visible text, table structure
All formatting, images, headers
Word → Markdown
Headings, tables, bold/italic, images (base64)
Exact font/size/color, custom styles
Word → HTML
Headings, tables, bold/italic, colors, fonts, images (base64)
Custom paragraph spacing, section breaks
Markdown → Word
Headings, paragraphs, lists, bold/italic, code, links, blockquotes
Embedded images become links
HTML → Word
Headings, paragraphs, lists, tables, bold, links, base64 images
CSS classes, external stylesheets
Text → Word
Paragraph structure (double-newline split)
All formatting
📚 Related Resources
User GuideFormattingFluent APILast updated
Was this helpful?
