Markdown to PDF Converter
A powerful VS Code extension that converts Markdown files to professionally formatted PDF documents using Playwright.
Features
- 🚀 One-Click Conversion: C- 🐛 Report Issues
- 💡 Feature Requests
- 📖 Documentation
- ⭐ Star the repo if you find it useful!rt Markdown files to PDF with a single command
- 🎨 Syntax Highlighting: Preserves code block formatting with syntax highlighting using Highlight.js
- 📄 Professional Output: Clean, readable PDF documents using Playwright rendering engine
- ⚡ Fast Processing: Efficient conversion using browser-grade rendering
- 💾 Flexible Output: Choose where to save your PDF files
- 🖼️ Image Support: Automatically includes images from your Markdown files
Installation
From VS Code Marketplace
- Open VS Code
- Press
Ctrl+P / Cmd+P to open Quick Open
- Type
ext install md-to-pdf
- Press Enter
From Source
- Clone this repository
- Run
npm install
- Run
npm run compile
- Press
F5 to launch Extension Development Host
Usage
Method 1: Command Palette
- Open a Markdown file (
.md)
- Press
Ctrl+Shift+P / Cmd+Shift+P
- Type "Export Markdown to PDF"
- Press Enter
- Choose output location for your PDF
- Right-click in a Markdown file editor
- Select "Export Markdown to PDF"
- Choose output location
Method 3: Editor Context (Right-click)
- Right-click anywhere in the Markdown editor
- Select "Export Markdown to PDF" from the context menu
Example
# My Document
This is a sample markdown document.
## Features
- Bullet points
- **Bold text**
- *Italic text*
## Code Example
```javascript
function hello() {
console.log('Hello, World!');
}
### Output:
A professionally formatted PDF with:
- Clean typography
- Proper heading hierarchy
- Syntax-highlighted code blocks
- Preserved formatting and styles
## Requirements
- VS Code version 1.107.0 or higher
- Node.js 16.x or higher (bundled with extension)
- Playwright (automatically included with extension)
## Configuration
Currently, the extension uses sensible defaults:
- **Page Format**: A4
- **Margins**: 20mm top/bottom, 15mm left/right
- **Background**: Print backgrounds enabled
- **Code Highlighting**: GitHub style theme
Future versions will include customizable settings:
```json
{
"mdToPdf.outputPath": "${fileDir}",
"mdToPdf.pageFormat": "A4",
"mdToPdf.margins": {
"top": "20mm",
"bottom": "20mm",
"left": "15mm",
"right": "15mm"
},
"mdToPdf.openAfterConversion": true
}
Supported Markdown Features
- ✅ Headings (H1-H6)
- ✅ Bold, Italic, Strikethrough
- ✅ Lists (ordered and unordered)
- ✅ Code blocks with syntax highlighting
- ✅ Inline code
- ✅ Links
- ✅ Images (local and remote)
- ✅ Blockquotes
- ✅ Tables
- ✅ Horizontal rules
- ✅ HTML (embedded)
Known Limitations
- Large images may affect conversion time
- Some advanced Markdown extensions may not be fully supported
- Custom CSS styling not yet available (planned for future release)
- Batch conversion not yet supported
Troubleshooting
Conversion fails or produces blank PDFs
- Ensure Playwright is properly installed:
npx playwright install
- Try restarting VS Code
- Check the Output panel (View → Output → "MD to PDF") for error messages
Images not appearing in PDF
- Verify image paths are correct (relative paths work best)
- Ensure images are accessible from the Markdown file location
- Check that image URLs are valid for remote images
"No active editor" error
- Make sure you have a Markdown file open and focused
- The file must have a
.md extension
- Small files (< 100 KB): ~1-2 seconds
- Medium files (100 KB - 1 MB): ~2-5 seconds
- Large files (> 1 MB): ~5-10 seconds
Conversion time depends on content complexity, number of images, and system performance.
Roadmap
- [ ] Batch conversion support (multiple files)
- [ ] Custom CSS themes and styling
- [ ] Configurable page settings via VS Code settings
- [ ] Table of contents generation
- [ ] Header/footer templates with page numbers
- [ ] Preview PDF before saving
- [ ] Custom output filename templates
- [ ] Watch mode for auto-conversion on save
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
Development
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Watch for changes
npm run watch
# Run tests
npm test
# Package extension
npm run package
License
MIT License - see LICENSE file for details.
Support
Changelog
See CHANGELOG.md for version history and release notes.
Acknowledgments
Enjoy converting your Markdown files to PDF! 📄✨
Following extension guidelines
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
Working with Markdown
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
- Split the editor (
Cmd+\ on macOS or Ctrl+\ on Windows and Linux).
- Toggle preview (
Shift+Cmd+V on macOS or Shift+Ctrl+V on Windows and Linux).
- Press
Ctrl+Space (Windows, Linux, macOS) to see a list of Markdown snippets.
Enjoy!