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

html2pdf-slides

v1.0.4

Published

Convert HTML slide decks to high-fidelity PDF files

Downloads

620

Readme

html2pdf-slides

Convert HTML slide presentations to high-fidelity PDF files. Automatically detects your slide framework and captures every slide, including animations, fragments, and click-reveal content.

demo

Works with reveal.js, Slidev, Marp, impress.js, custom HTML slides, and any HTML presentation that uses arrow-key navigation.

Quick Start

# Install globally
npm install -g html2pdf-slides

# Or use without installing
npx html2pdf-slides https://revealjs.com/demo/ -o slides.pdf
# Local file
html2pdf-slides presentation.html -o output.pdf

# Online reveal.js presentation
html2pdf-slides https://revealjs.com/demo/ -o revealjs-demo.pdf

# Slidev deck (from deployed URL, no source code needed)
html2pdf-slides https://your-slidev-deck.netlify.app/ -o deck.pdf

# Marp presentation
html2pdf-slides https://yhatt.github.io/marp-cli-example/ -o marp.pdf

Why html2pdf-slides?

Most HTML-to-PDF tools treat your presentation like a static webpage. They miss animations, break dark themes, and collapse slide layouts.

html2pdf-slides uses framework-native APIs to navigate through every slide and fragment state, captures pixel-perfect screenshots, and assembles them into a clean PDF with correct dimensions and background colors.

Supported Frameworks

| Framework | How it captures | |-----------|----------------| | reveal.js | Uses Reveal.next() to walk all slides, vertical slides, and fragment steps | | Slidev | URL-based navigation with full v-click content reveal (all 8 hidden states) | | Marp | Hash navigation via bespoke.js | | impress.js | impress().goto() API for 3D-transformed steps | | Quarto reveal.js | Waits for async Reveal.js initialization, then uses Reveal API | | Custom HTML (.slide class) | html2canvas capture, auto-discovers all .slide elements | | Shower | Same as above, detected via .slide class | | Any other HTML slides | Keyboard fallback (ArrowRight, Space, PageDown) with screenshot deduplication |

Comparison

| | html2pdf-slides | DeckTape | Browser Print | Native export | |---|---|---|---|---| | Setup | Auto-detect, zero config | Needs --plugins flag | Manual | Needs source code | | Dark themes | Preserved | Preserved | Stripped to white | Varies | | Fragments | Every state | Every state | Final state only | Varies | | Slidev v-click | All 8 states | Partial | No | Yes | | Slide backgrounds | Per-slide sampling | Single color | White | Varies | | Quarto support | Yes (async wait) | May fail | No | N/A | | Fallback for unknowns | Multi-key + dedup | Single method | N/A | N/A |

Native export refers to built-in tools like reveal.js ?print-pdf, slidev export, or marp-cli. These require project source code and local dev setup. html2pdf-slides works from any deployed URL.

How It Works

  1. Detect the slide framework from DOM markers
  2. Navigate using framework-native APIs (not generic scrolling)
  3. Capture pixel-perfect screenshots at original viewport size
  4. Assemble into PDF with per-slide background colors and 16:9 minimum page dimensions

Options

| Flag | Description | Default | |------|-------------|---------| | -o, --output <path> | Output PDF path | same as input | | -s, --selector <css> | CSS selector for slides | .slide | | -b, --bg-color <hex> | Background color | #0a0a0a | | --scale <n> | Resolution multiplier | 1.5 | | --quality <n> | JPEG quality (1-100) | 88 | | --page-width <pts> | PDF page width | 842 | | --parallel <n> | Parallel browser tabs | 2 | | --wait <ms> | Wait before capture | 300 | | --retry <n> | Retry for blank slides | 2 | | --no-headless | Show browser window | |

Programmatic API

import { convertToPDF } from 'html2pdf-slides';

const result = await convertToPDF({
  input: 'https://revealjs.com/demo/',
  output: 'slides.pdf',
  quality: 90,
  onProgress: (current, total) => {
    console.log(`Capturing slide ${current}/${total}`);
  },
});

// result: { slideCount, blankCount, pdfSize, outputPath, framework }

FAQ

How do I convert reveal.js slides to PDF?

html2pdf-slides https://your-reveal-presentation.com -o output.pdf

Automatically detects reveal.js and uses the Reveal API to navigate through all slides and fragments. Preserves your theme, animation final states, and dark backgrounds.

How do I convert Slidev presentations to PDF?

html2pdf-slides https://your-slidev-deck.netlify.app -o output.pdf

Converts any deployed Slidev presentation directly from its URL. No source code needed. Fully handles v-click content visibility.

Can I convert any HTML presentation to PDF?

Yes. For unrecognized frameworks, it falls back to keyboard navigation with screenshot deduplication to detect when all slides have been captured.

Why are some slides blank in the output?

Try increasing the wait time for slides that rely on lazy loading:

html2pdf-slides presentation.html --wait 1000 -o output.pdf

Requirements

  • Node.js 18 or later
  • Chromium is downloaded automatically by Puppeteer on first run

License

MIT