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:


