Print your Markdown files directly to any printer with a beautiful preview β no browser needed.
- π¨οΈ Print Markdown files directly from VS Code to any office printer
- π Live Preview before printing with accurate page breaks
- π Letter-sized pages (US Letter) with professional formatting
- π Page Range Selection β print specific pages (e.g., 1-3, 5, 7-9)
- π¨ GitHub-style rendering matching VS Code's markdown preview
- π±οΈ Right-click anywhere β works in editor and preview pane
- πΎ Save as PDF option instead of printing
- π§ Printer Selection β remember last used printer or always use default
- π Cross-Platform β Windows, macOS, and Linux support
- Node.js (for VS Code extension)
- Python 3.x with pip
- Clone or download this extension
- Run one command:
npm installThat's it! The postinstall script will:
- Compile TypeScript code
- Install Python dependencies automatically (platform-specific)
- Set up everything for your operating system
If you encounter "externally-managed-environment" errors, the installer will automatically try multiple strategies. If all fail, you can install manually:
# Option 1: Use --break-system-packages (quickest, recommended for Homebrew Python)
python3 -m pip install --break-system-packages markdown weasyprint pygments
# Option 2: Install with --user flag (if allowed)
python3 -m pip install --user markdown weasyprint pygments
# Option 3: Use a virtual environment (recommended for development)
python3 -m venv .venv
source .venv/bin/activate
pip install markdown weasyprint pygments
# Option 4: Use Homebrew (some packages may not be available)
brew install python-markdown
pip3 install --break-system-packages weasyprint pygmentsOn Windows, the extension automatically installs pywin32 for better printer integration. Python packages install to the system or user Python environment.
Similar to macOS, uses the --user flag for externally-managed environments. No Windows-specific packages are installed.
If automatic installation fails, install manually:
All Platforms:
python3 -m pip install markdown weasyprint pygmentsWindows Only (additional):
python -m pip install pywin32- Open any Markdown file (
.md) - Right-click in the editor or preview pane
- Select "Print Markdown"
- Review the preview with accurate page breaks
- (Optional) Select page range β print all pages, current page, or custom range (e.g., 1-3, 5, 7-9)
- (Optional) Choose printer β or save as PDF
- Click Print π
- Open any
.mdfile - Right-click anywhere in the editor
- Select "Print Markdown"
- Review, configure, and print
- Open markdown preview (Ctrl+Shift+V / Cmd+Shift+V)
- Right-click in the preview pane
- Select "Print Markdown"
- Review, configure, and print
In the print preview, you can select which pages to print:
- All Pages β Print the entire document
- Current Page β Print only the page you're viewing
- Custom Range β Specify pages like:
3β Just page 31-5β Pages 1 through 51-3, 5, 7-9β Pages 1-3, page 5, and pages 7-9
Configure printer behavior in VS Code settings:
Use property vscode-print-md.printer.select, and set value to one of:
- default β Always use system default
- last-used β Remember and reuse last selected printer
- save-pdf β Always save as PDF instead of printing
{
"vscode-print-md.printer.select": "default" | "last-used" | "save-pdf"
}Press F5 in VS Code to launch Extension Development Host
npm run compile # Single compile
npm run watch # Watch modevscode-print-md/
βββ src/
β βββ extension.ts # Main extension code
β βββ printMD.py # Python printing engine
β βββ utils/
β β βββ cleanTemp.ts # Temp folder cleanup utility
β βββ views/
β βββ addPrintButton.htm # Print button UI template
β βββ createPrintableHtml.htm # Printable HTML template
β βββ mdToHtml.htm # Markdown to HTML template
βββ scripts/
β βββ install-python-deps.js # Cross-platform Python installer
βββ test/
β βββ coding-standards.test.js # Code style validation
β βββ print/ # Test markdown files
βββ out/ # Compiled JavaScript output
βββ package.json # Extension manifest
βββ tsconfig.json # TypeScript configuration
- Extension uses VS Code's native
markdown.api.renderto convert markdown to HTML - Applies print-friendly CSS styling
- Shows preview in webview with page breaks
- On confirmation, Python script converts HTML β PDF using WeasyPrint
- PDF sent to system printer (platform-specific handling)
- VS Code 1.80.0 or higher
- Python 3.x with packages:
markdown- Markdown processingweasyprint- HTML to PDF conversionpygments- Syntax highlighting
- Python 3.x with packages:
pywin32- Windows printer integration (Windows only)
The extension works seamlessly across all major platforms:
| Platform | Print Method | Fallback Behavior |
|---|---|---|
| Windows | Native printer integration via pywin32 |
Opens PDF with default viewer if printing fails |
| macOS | System lp command |
Opens PDF in Preview app for manual printing |
| Linux | System lp or lpr command |
Opens PDF in default viewer (xdg-open) |
The extension intelligently handles printing across platforms:
- Direct Printing (preferred): Sends PDF directly to printer using system commands
- Fallback Mode: If direct printing fails or no printer is available, opens PDF in system default viewer
- Allows manual printing with full control over printer settings
- Useful when printer isn't detected or requires special configuration
If you see "Python is not installed" warning:
Windows:
# Install Python from Microsoft Store or python.org
# Ensure 'python' command works in terminal
python --versionmacOS/Linux:
# Install Python 3 if not already installed
python3 --version
# Extension automatically detects python3 on Unix systemsmacOS "externally-managed-environment" error:
The extension installer handles this automatically. If manual installation is needed:
python3 -m pip install --break-system-packages markdown weasyprint pygmentsLinux permission errors:
python3 -m pip install --user markdown weasyprint pygmentsColors not printing:
Check your PDF viewer settings:
- Adobe Reader: Disable "Print in Grayscale"
No printers detected:
The extension will automatically open the PDF in your default viewer for manual printing.
Page breaks in wrong places:
Page breaks are calculated during preview. Adjust your markdown formatting or use manual page break hints if needed.
If you encounter issues:
- Check the Output panel (View β Output β Select "Print Markdown")
- Enable debug mode by searching for debug settings
- Report issues with OS, Python version, and error messages
Contributions are welcome! Please feel free to submit issues or pull requests.
git clone https://github.com/isocialPractice/vscode-print-md.git
cd vscode-print-md
npm install # Installs Node and Python dependenciesPress F5 in VS Code to launch the Extension Development Host.
MIT License β Copyright (c) 2025 practicing.xyz
See LICENSE file for details.
Enjoy printing your Markdown files! π