CONVERT WORD TO HTML, EPUB, AND MORE

With the new docx2epubdocx2htmldocx2markdown, and docx2txt commands, you can convert Word™ documents (.docx files) to EPUB, HTML, Markdown, and plain text formats. Whether you create a report with Stata results by using putdocx or you have an existing Word document, you can easily convert your document to any of these formats. This feature is a part of StataNow™.


CONVERT A WORD (.DOCX) DOCUMENT TO AN EPUB FILE

We have a Word document, graphs.docx, that contains some Stata graphs; you can download this file to your current working directory by typing

 

. copy https://www.stata-press.com/data/r19/reporting/graphs.docx .

 

We convert this file to an EPUB file by typing

 

. docx2epub graphs.docx

 

We obtain the EPUB file graphs.epub. Below, we view a snippet of the file with Adobe Digital Editions, but you can open it with any other electronic reading platform that supports .epub files.

 


CONVERT A WORD (.DOCX) DOCUMENT TO AN HTML FILE

Below, we work with the same Word document as above, graphs.docx. We convert this file to an HTML file by typing

 

. docx2html graphs.docx

 

We obtain the HTML file graphs.html:

 

CONVERT A WORD (.DOCX) DOCUMENT TO A MARKDOWN FILE

Additionally, you can convert a Word document to a Markdown file. For example, you may want to convert graphs.docx to Markdown and make further modifications before converting it to HTML.

 

© Copyright 1996–2026 StataCorp LLC. All rights reserved.

We convert graphs.docx to a Markdown file by typing

 

. docx2markdown graphs.docx

 

We obtain the Markdown file graphs.md:

 

The graphs are extracted and saved as graphs.001.png and graphs.002.png.

CONVERT A WORD (.DOCX) DOCUMENT TO A PLAIN TEXT FILE

Unlike EPUB and HTML files, plain text files cannot contain embedded images. Therefore, we use the putdocx suite of commands to create a file with a table of descriptive statistics and a table of regression results. We use data from the Second National Health and Nutrition Examination Survey (NHANES II) (McDowell et al. 1981) to analyze blood pressure, weight, and body mass index. We run the following commands to create our .docx file:

 

. webuse nhanes2l, clear
. putdocx begin
. putdocx paragraph
. putdocx text ("We analyze data from the Second National Health and")
. putdocx text (" Nutrition Examination Survey."), linebreak(1)
. quietly: dtable bpsystol weight bmi, by(diabetes)
     title("Table 1. Descriptive statistics")
     column(by(, halign(right)) total(, halign(right)))
. putdocx collect
. regress bpsystol age weight
. putdocx table bweight = etable, title("Table 2. Linear regression of systolic blood pressure")
. putdocx save bpreport, replace

 

And now we convert bpreport.docx to a plain text file by typing

 

. docx2txt bpreport.docx

 

Here is our plain text file: