
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
@govindkm/mdtopdf-converter
Advanced tools
A powerful CLI tool for converting Markdown and HTML files to PDF with 10 built-in templates, dark theme support, and custom template management
A powerful, professional CLI tool for converting Markdown and HTML files to PDF with 10 built-in templates, dark theme support, and custom template management.
# Clone the repository
git clone <repository-url>
cd MDTOPDFConverter
# Install dependencies
npm install
# Build the project
npm run build
# Test installation
npm run dev -- --help
# Convert single file
mdtopdf convert document.md
# Convert with specific template
mdtopdf convert document.md -t github-dark
# Batch convert all markdown files
mdtopdf convert *.md -o output/
# Interactive file selection
mdtopdf convert -i -p "**/*.md"
github - Clean GitHub-style markdownacademic - Professional academic papersminimal - Minimalist design focused on contentmodern - Contemporary with colors and gradientsnewspaper - Multi-column newspaper layoutgithub-dark - GitHub with complete dark background (#0d1117)academic-dark - Academic papers with full dark theme (#1a1a1a)minimal-dark - Clean dark design with dark background (#1a1a1a)modern-dark - Modern with dark theme and neon accents (#0f172a)newspaper-dark - Dark newspaper with vintage styling (#1a1a1a)✨ Special Feature: These are true dark themes that maintain dark backgrounds in the final PDF, perfect for night reading, presentations, and modern aesthetics.
# List all templates
mdtopdf templates list
# Add custom template
mdtopdf templates add my-style.css -n "My Template"
# Remove custom template
mdtopdf templates remove template-id
Set your preferences once, use everywhere:
# View current configuration
mdtopdf config show
# Set default template
mdtopdf config set defaultTemplate modern-dark
# Set default page format
mdtopdf config set defaultFormat A3
# Reset to defaults
mdtopdf config reset
# Single file with GitHub template
mdtopdf convert README.md -t github
# Multiple files with output directory
mdtopdf convert *.md -o pdfs/ -t academic-dark
# Recursive pattern matching
mdtopdf convert -p "docs/**/*.md" -r -t minimal
# Custom margins and format
mdtopdf convert doc.md -m "20mm,15mm,20mm,15mm" -f A3
# Interactive selection with custom template
mdtopdf convert -i -p "*.md" -t ./my-styles.css
# High quality output
mdtopdf convert report.md -q 100 -t modern
# Convert all markdown files in project
mdtopdf convert -p "**/*.md" -r -o output/
# Convert with custom settings
mdtopdf convert *.md -t newspaper-dark -f Letter -o reports/
mdtopdf convert [input...] [options]
Options:
-o, --output <path> Output file or directory
-p, --pattern <pattern> File pattern (e.g., "*.md", "**/*.html")
-r, --recursive Search recursively in subdirectories
-i, --interactive Interactive file selection mode
-t, --template <name> Template name or CSS file path
-m, --margins <margins> PDF margins: "top,right,bottom,left"
-f, --format <format> PDF page format (A4, A3, A5, Letter, etc.)
-q, --quality <number> PDF quality (0-100, default: 80)
mdtopdf templates <subcommand>
Subcommands:
list List all available templates
add <css-file> [options] Add a custom template
remove <template-id> Remove a custom template
mdtopdf config <subcommand>
Subcommands:
show Show current configuration
set <key> <value> Set configuration option
reset Reset configuration to defaults
dir Show configuration directories
| Key | Description | Valid Values |
|---|---|---|
defaultTemplate | Default template for conversions | Any template name or ID |
defaultFormat | Default PDF page format | A4, A3, A5, Letter, Legal, Tabloid |
defaultMargins | Default PDF margins | "top,right,bottom,left" (e.g., "20mm,20mm,20mm,20mm") |
theme | Theme preference | light, dark, auto |
~/.mdtopdf/ # Configuration directory
├── config.json # User preferences
└── templates/ # Custom templates
├── my-template.css # Custom template files
└── metadata.json # Template metadata
src/
├── cli/ # CLI commands and interface
│ ├── index.ts # Main CLI entry point
│ └── command.ts # Command definitions
├── core/ # Core functionality
│ ├── converter.ts # Main conversion orchestrator
│ ├── fileProcessor.ts # File discovery and processing
│ ├── pdfGenerator.ts # PDF generation with Puppeteer
│ ├── templateManager.ts # Template management system
│ └── configManager.ts # Configuration management
├── utils/ # Utilities
│ └── validator.ts # Input validation
└── types/ # TypeScript type definitions
└── index.ts # Shared interfaces and types
# Development mode with hot reload
npm run dev -- convert file.md
# Build TypeScript to JavaScript
npm run build
# Run tests (if implemented)
npm test
# Type checking
npx tsc --noEmit
mdtopdf templates add my-style.cssmdtopdf convert file.md -t my-template-idSee TEMPLATE_GUIDE.md for detailed template development guide.
Template not found
# Check available templates
mdtopdf templates list
# Verify spelling
mdtopdf config show
File not found
# Check file exists
ls -la your-file.md
# Use absolute paths if needed
mdtopdf convert /full/path/to/file.md
Permission errors
# Check output directory permissions
ls -ld output/
# Create directory if needed
mkdir -p output/
# Enable verbose logging (if available)
DEBUG=mdtopdf:* mdtopdf convert file.md
Our dark themes use advanced CSS and Puppeteer configuration to create genuine dark PDFs:
/* Full page dark background */
html, body {
background-color: #0d1117 !important;
margin: 0 !important;
min-height: 100vh !important;
}
@media print {
@page { margin: 0 !important; }
body {
background-color: #0d1117 !important;
-webkit-print-color-adjust: exact !important;
print-color-adjust: exact !important;
}
}
// Zero margins for dark themes to eliminate white borders
const pdfOptions = {
printBackground: true,
margin: { top: '0mm', right: '0mm', bottom: '0mm', left: '0mm' }
};
// Color preservation
await page.addStyleTag({
content: `* {
-webkit-print-color-adjust: exact !important;
print-color-adjust: exact !important;
}`
});
Result: PDFs with complete dark backgrounds and no white borders - true dark theme PDFs!
git checkout -b feature/amazing-featuregit commit -m 'Add amazing feature'git push origin feature/amazing-featureThis project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ for developers who love beautiful PDFs
Start converting with: mdtopdf convert your-file.md -t modern-dark
FAQs
A powerful CLI tool for converting Markdown and HTML files to PDF with 10 built-in templates, dark theme support, and custom template management
We found that @govindkm/mdtopdf-converter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.