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

nuxt-pdfmake

v0.1.4

Published

Easily generate PDFs in Nuxt.js using pdfmake

Readme

Nuxt PDFMake

npm version npm downloads License Nuxt CI Last commit Package size Conventional Commits

Easily add pdfMake to your Nuxt application.

Deployment Status

Netlify Status

Features

  • usePDFMake composable auto-imported on the client
  • Server-side PDF generation via createPDFBuffer, createPDFBase64, and useServerPDFMake
  • Optional reuse of fonts resolved by @nuxt/fonts without embedding them in client JavaScript
  • Pre-built POST /_pdfmake/generate API endpoint (dev only by default)
  • Font management — embed custom fonts, load Google Fonts at build time, or reference CDN URLs
  • Nuxt DevTools panel to inspect fonts and module config

Quick Setup

# Using bun
bun add -D nuxt-pdfmake

# Using pnpm
pnpm add -D nuxt-pdfmake

# Using yarn
yarn add --dev nuxt-pdfmake

# Using npm
npm install --save-dev nuxt-pdfmake

Add nuxt-pdfmake to the modules section of nuxt.config.ts:

export default defineNuxtConfig({
  modules: ["nuxt-pdfmake"],
});

That's it! You can now use Nuxt PDFMake in your Nuxt app ✨

Usage

Client-side

Use the auto-imported usePDFMake composable inside a Vue component:

const pdfMake = usePDFMake();

const doc = pdfMake!.createPdf({ content: ["Hello, world!"] });
doc.open(); // opens in a new browser tab
doc.download("my-file.pdf");

Or access the instance directly via the Nuxt app plugin:

const { $pdfMake } = useNuxtApp();

Server-side (Nitro handlers)

Use the server utilities inside server/api/ or server/routes/:

// server/api/report.get.ts
export default defineEventHandler(async (event) => {
  const buffer = await createPDFBuffer({ content: ["Hello from the server!"] });
  setHeader(event, "Content-Type", "application/pdf");
  return buffer;
});

| Utility | Returns | Description | |---|---|---| | createPDFBuffer(docDefinition) | Promise<Buffer> | Generate a PDF as a Node.js Buffer | | createPDFBase64(docDefinition) | Promise<string> | Generate a PDF as a base64 string | | useServerPDFMake() | pdfmake instance | Access the raw server-side pdfmake instance |

Pre-built API endpoint

A POST /_pdfmake/generate endpoint is included and enabled in development. Send a docDefinition in the request body to receive a PDF:

const { data } = await useFetch("/_pdfmake/generate", {
  method: "POST",
  body: { docDefinition: { content: ["Hello, PDF!"] } },
  responseType: "blob",
});

To enable in production, set enableApiRoute: true in your module options and add your own auth middleware.

Font Configuration

Configure fonts via the pdfmake key in nuxt.config.ts:

export default defineNuxtConfig({
  modules: ["nuxt-pdfmake"],
  pdfmake: {
    fonts: {
      // Local font files (embedded as base64 at build time — ~270 KB per variant)
      custom: {
        MyFont: {
          normal: "assets/fonts/MyFont-Regular.ttf",
          bold: "assets/fonts/MyFont-Bold.ttf",
        },
      },

      // Google Fonts downloaded and cached at build time (~1 MB per family)
      googleFonts: ["Roboto", "Lato"],

      // CDN/HTTP URLs fetched at PDF-creation time
      cdn: {
        OpenSans: {
          normal: "https://fonts.example.com/OpenSans-Regular.ttf",
        },
      },

      // Set to false to opt out of the default Roboto font
      useDefaultRoboto: true,
    },
  },
});

When no fonts are configured, the default Roboto font from the pdfmake CDN is used automatically.

Module Options

| Option | Type | Default | Description | |---|---|---|---| | enabled | boolean | true | Enable or disable the module | | enableComposable | boolean | true | Auto-import usePDFMake and server utilities | | enableDevtools | boolean | true | Show the PDFMake panel in Nuxt DevTools | | enableApiRoute | boolean | true (dev only) | Expose POST /_pdfmake/generate | | fonts.custom | Record<string, TFontFamilyTypes> | — | Local font files embedded at build time | | fonts.googleFonts | string[] | — | Google Font family names fetched at build time | | fonts.cdn | Record<string, TFontFamilyTypes> | — | CDN font URLs passed directly to pdfmake | | fonts.useDefaultRoboto | boolean | true (when no fonts set) | Include pdfmake's default Roboto CDN font |

Development

# Install dependencies
bun install
(cd docs && bun install)

# Run the docs site against the local module (stub build + docs dev server)
bun run dev

# Run linter / tests / type check
bun run lint
bun run test
bun run test:types

# Build the module
bun run prepack

# Release a new version
bun run release