VS Code Extensions
MD to PDF

MD to PDF

by SwastikaGupta

Export Markdown files to PDF using Playwright with syntax highlighting

Downloads

1,165

Rating

5.0 / 5 (1)

Version

0.0.2

Last updated

Jul 11, 2026

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

  1. Open VS Code
  2. Press Ctrl+P / Cmd+P to open Quick Open
  3. Type ext install md-to-pdf
  4. Press Enter

From Source

  1. Clone this repository
  2. Run npm install
  3. Run npm run compile
  4. Press F5 to launch Extension Development Host

Usage

Method 1: Command Palette

  1. Open a Markdown file (.md)
  2. Press Ctrl+Shift+P / Cmd+Shift+P
  3. Type "Export Markdown to PDF"
  4. Press Enter
  5. Choose output location for your PDF

Method 2: Context Menu

  1. Right-click in a Markdown file editor
  2. Select "Export Markdown to PDF"
  3. Choose output location

Method 3: Editor Context (Right-click)

  1. Right-click anywhere in the Markdown editor
  2. Select "Export Markdown to PDF" from the context menu

Example

Input Markdown:

# 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

Performance

  • 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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.

For more information

Enjoy!

Related extensions