npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tafaju/md-to-pdf

v1.0.5

Published

Convert Markdown with Mermaid, LaTeX, and PlantUML diagrams to professional print-ready PDFs

Downloads

67

Readme

@tafaju/md-to-pdf

Convert Markdown to professional, print-ready PDFs with built-in support for Mermaid diagrams, LaTeX math, PlantUML diagrams, and syntax-highlighted code blocks.

Install

npm install -g @tafaju/md-to-pdf

Requires Node.js >= 18.

Usage

md-to-pdf document.md

This generates document.pdf in the same directory.

Options

| Option | Description | Default | |---|---|---| | -o, --output <path> | Output PDF path | <input>.pdf | | -f, --format <size> | Page format: A4, Letter, Legal | A4 | | -m, --margin <mm> | Page margin in mm | 20 | | --css <path> | Additional CSS file to include | — | | --no-mermaid | Disable Mermaid rendering | — | | --no-latex | Disable LaTeX math rendering | — | | --no-plantuml | Disable PlantUML rendering | — | | --plantuml-jar <path> | Path to plantuml.jar | — | | --mermaid-theme <theme> | default, dark, forest, neutral | default | | -v, --verbose | Verbose logging | — |

Examples

# Basic conversion
md-to-pdf report.md

# Custom output path and Letter format
md-to-pdf report.md -o ~/Desktop/report.pdf -f Letter

# With custom branding CSS
md-to-pdf report.md --css my-brand.css

# Wider margins, no Mermaid
md-to-pdf report.md -m 30 --no-mermaid

Features

Mermaid Diagrams

Fenced code blocks with the mermaid language are rendered as SVG diagrams:

```mermaid
graph LR
  A[Start] --> B[End]
```

LaTeX Math

Inline math with $...$ and display math with $$...$$ are rendered via KaTeX:

The quadratic formula is $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.

PlantUML Diagrams

Fenced code blocks with plantuml or puml are rendered as SVG diagrams (requires plantuml.jar):

```plantuml
@startuml
Alice -> Bob: Hello
@enduml
```

Syntax Highlighting

Code blocks are syntax-highlighted using highlight.js with the GitHub theme. Over 180 languages are supported.

Custom CSS

Pass a CSS file with --css to override the default styles. An example brand stylesheet is included at styles/example-brand.css with all customizable properties documented.

Utility classes you can use directly in your Markdown via HTML:

  • <div class="page-break"></div> — force a page break
  • <div class="no-break">...</div> — keep content on the same page
  • <div class="two-col">...</div> — two-column layout
  • <div class="callout">...</div> — highlighted callout box

Programmatic API

import { convertMarkdownToPdf } from "@tafaju/md-to-pdf";

await convertMarkdownToPdf("document.md", {
  output: "output.pdf",
  format: "Letter",
  margin: 25,
  mermaid: true,
  latex: true,
  css: "brand.css",
});

License

MIT