Md2Docs is a professional VS Code extension that enables you to preview and export your Markdown files into styled, formatted Word (.docx) and PDF documents. Directly within VS Code, you can preview the rendered output in real A4 pages, choose between multiple elegant templates, and export high-fidelity documents ready for distribution.
Paginated A4 Preview: See exactly what your document will look like when printed or saved. The in-editor preview slices your content into standard A4 pages with accurate headers/footers and page numbering.
Native Word (.docx) Export: Generates true Open XML Word documents (using the docx library), meaning they are fully editable and compatible with Microsoft Word, Google Docs, LibreOffice, and Pages. No quick HTML wrapping hacks.
High-Fidelity PDF Export: Generate pixel-perfect PDFs from the visual pages directly from your editor.
Interactive Style & Template Panel: Toggle between different styles, customize margins, headers, typography, tables, and colors, and see the preview update in real-time.
Editor Context Menu & Icons: Open previews, export PDF, or save Word files directly from the editor's title bar icons or the File Explorer context menu (right-click any .md file).
🛠️ How to Use
Open any Markdown (.md) file in VS Code.
Open the Md2Docs sidebar or click the Open Preview icon in the editor title bar.
In the sidebar panel:
Preview the paginated layout.
Choose a layout/color template that matches your document style.
Click Save as Word (.docx) or Save as PDF to export your document.
⚡ Extension Commands
Md2Docs registers the following commands in VS Code:
md-to-docs.preview: Open the real-time paginated preview sidebar.
md-to-docs.exportDocx: Export the current Markdown file to Word (.docx).
md-to-docs.exportPdf: Export the current Markdown file to PDF.
🎨 Advanced Formatting Features
Robust Link Bookmarks: Headers automatically receive bookmark anchors, enabling clickable Table of Contents (TOC) links in both Word and PDF.
Ordered List Continuation: Literal list start numbers (e.g. 3.) are preserved even when interrupted by code blocks or diagrams.
Auto-Fitting Code Blocks: Long lines in code blocks automatically adjust their font size to fit the page width, avoiding ugly word wrapping or clipping.
Paginated Code Blocks: Long code blocks spanning multiple pages split gracefully across page breaks.