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

convert2pdf

v1.0.0

Published

Convert files to PDF and compress PDFs. Currently supports .pptx/.ppt to PDF and .pdf compression. CLI and Node.js API.

Readme

convert2pdf

Convert PowerPoint (.pptx, .ppt) to PDF and compress PDFs from the terminal — with an interactive wizard, live progress, and Ghostscript compression presets.

Built because I needed to convert large presentation files to PDF locally and fast, without uploading decks to online converters or waiting on slow cloud tools. Everything runs on your machine: convert with LibreOffice, then shrink the PDF with Ghostscript when you want a smaller file.

Fully built with Cursor.

Supported formats (current)

| Input | Output | |-------|--------| | .pptx, .ppt | PDF | | .pdf | Compressed PDF |

Install globally:

npm install -g convert2pdf

Or install in a project:

npm install convert2pdf

Or run once with npx:

npx convert2pdf

Features

  • .pptx / .ppt to PDF via LibreOffice (headless)
  • PDF compression via Ghostscript (screen, ebook, printer, prepress)
  • Compress-only mode — pass a .pdf file (auto-detected) or use --compress-only
  • Interactive wizard — guided prompts with descriptions
  • Live progress — elapsed time and stage updates while converting/compressing
  • Programmatic API — import in Node.js backends and wire progress to your own UI

Prerequisites

| Tool | When needed | macOS install | |------|-------------|---------------| | LibreOffice | .pptx / .ppt conversion | brew install --cask libreoffice | | Ghostscript | Any compression | brew install ghostscript |

Ghostscript

| OS | Command | |----|---------| | macOS | brew install ghostscript | | Ubuntu / Debian | sudo apt install -y ghostscript | | Windows | choco install ghostscript or download |

LibreOffice

| OS | Command | |----|---------| | macOS | brew install --cask libreoffice | | Ubuntu / Debian | sudo apt install -y libreoffice | | Windows | Download installer |

Usage

Interactive wizard (default)

convert2pdf

Accepts .pptx, .ppt, or .pdf paths. PDF inputs go straight to compression.

.pptx / .ppt to PDF

convert2pdf slides.pptx
convert2pdf slides.pptx -o output.pdf -l screen
convert2pdf slides.pptx --no-compress

Compress PDF only

Auto-detected when the input ends with .pdf:

convert2pdf document.pdf
convert2pdf document.pdf -o smaller.pdf -l ebook

Or explicitly:

convert2pdf document.pdf --compress-only -l screen

Default output for PDF compression: document-compressed.pdf

Options

| Flag | Description | |------|-------------| | [file] | Input .pptx, .ppt, or .pdf (wizard if omitted) | | -o, --output <path> | Output PDF path | | -l, --level <level> | none, screen, ebook, printer, prepress (default: ebook) | | --no-compress | Convert to PDF only — skip compression (.pptx, .ppt) | | --compress-only | Compress a PDF (also auto-detected for .pdf inputs) | | -h, --help | Show help | | -V, --version | Show version |

Compression levels

| Level | DPI | Best for | |-------|-----|----------| | screen | 72 | Smallest files — web, email | | ebook | 150 | Balanced quality and size (recommended) | | printer | 300 | Print-ready documents | | prepress | 300 | Professional print workflows |

Programmatic API

Install as a dependency:

npm install convert2pdf

Use it from Node.js (server, API route, Electron main process, etc.). Conversion requires LibreOffice and Ghostscript on the machine running your code — it does not run in the browser.

Convert to PDF

import {
  prepareConversionOptions,
  runConversion,
} from 'convert2pdf';

const options = prepareConversionOptions({
  inputPath: './slides.pptx',
  outputPath: './slides.pdf',
  compressionLevel: 'ebook',
});

const result = await runConversion({
  ...options,
  silent: true,
  onProgress: (event) => {
    console.log(event);
  },
});

console.log(result.outputPath, result.finalSize);

Compress an existing PDF

import { prepareConversionOptions, runConversion } from 'convert2pdf';

const result = await runConversion({
  ...prepareConversionOptions({
    inputPath: './large.pdf',
    compressionLevel: 'screen',
  }),
  silent: true,
});

PDF inputs are detected automatically — compressOnly is implied when the path ends with .pdf.

Wire up a frontend UI

Call the library from your backend and stream progress to the client:

// server.ts (Express example)
import express from 'express';
import { prepareConversionOptions, runConversion } from 'convert2pdf';

const app = express();

app.post('/convert', async (req, res) => {
  const { inputPath, outputPath, level } = req.body;

  res.setHeader('Content-Type', 'text/event-stream');

  const result = await runConversion({
    ...prepareConversionOptions({
      inputPath,
      outputPath,
      compressionLevel: level ?? 'ebook',
    }),
    silent: true,
    onProgress: (event) => {
      res.write(`data: ${JSON.stringify(event)}\n\n`);
    },
  });

  res.write(`data: ${JSON.stringify({ type: 'result', result })}\n\n`);
  res.end();
});

Your React/Vue/Angular app uploads the file to the server, then listens to Server-Sent Events (or WebSockets) to show live progress in the UI.

API reference

| Export | Description | |--------|-------------| | runConversion(options) | Full pipeline: convert and/or compress | | prepareConversionOptions(opts) | Build options from paths and flags | | convertPptxToPdf(input, output) | .pptx / .ppt to PDF only | | compressPdfFile(input, output, level) | Compress a PDF only | | validateInputFile(path) | Validate input before running | | checkLibreOffice() | Check LibreOffice is installed | | checkGhostscript() | Check Ghostscript is installed | | getSupportedFormatsText() | Human-readable list of supported inputs | | SUPPORTED_FORMATS | .pptx/.ppt (convert) and .pdf (compress) | | getInputKind(path) | 'powerpoint' | 'pdf' | null | | defaultOutputPath(path) | Suggest an output path | | COMPRESSION_LEVELS | Preset metadata for UI dropdowns |

Progress events

When onProgress is set, you receive:

type ProgressEvent =
  | { type: 'start'; step: 'convert' | 'compress'; message: string; inputPath: string; inputSize?: number }
  | { type: 'stage'; step: 'convert' | 'compress'; message: string; elapsedMs: number; detail?: string }
  | { type: 'complete'; step: 'convert' | 'compress'; message: string; elapsedMs: number };

Use these to drive progress bars, status text, or logs in your own UI.

License

ISC