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

@papack/pdf

v1.0.3

Published

Minimal PDF rendering wrapper built on React and react-pdf

Readme

@papack/pdf

Minimal PDF rendering wrapper built on React and react-pdf.

This package provides a very small abstraction layer around React and @react-pdf/renderer.

Core Idea

  • JSX rendered directly to PDF (buffer)
  • Built on React + @react-pdf/renderer

This is PDF rendering only:
define document → render → buffer / file.

What this is

  • A thin wrapper
  • Some helpers (<For />, <Show />, <Repeat />)
  • A custom JSX runtime for controlled usage
  • Convenience utilities for layout and styling

Install

npm install @papack/pdf

Quick Start

import { jsx, render, Document, Page, Text } from "@papack/pdf";
import { writeFile } from "fs/promises";

const MyDocument = () => (
  <Document title="Example">
    <Page size="A4">
      <Text>Hello PDF</Text>
    </Page>
  </Document>
);

const buffer = await render(<MyDocument />);
await writeFile("example.pdf", buffer);

Rendering

import { render } from "@papack/pdf";

const buf = await render(<MyDocument />);
  • Returns a Buffer
  • Internally calls @react-pdf/renderer/pdf().toBuffer()

JSX Runtime

The package ships with a minimal JSX runtime.

import { jsx, fragment } from "@papack/pdf/core";
  • Uses React.createElement
  • No transforms, no extensions
  • Intended for controlled environments (Node.js)

Components

<For />

<For each={items}>{(item, index) => <Text>{item}</Text>}</For>
  • Simple array iteration
  • No keys
  • No diffing
  • Render-only

<Show />

<Show when={loggedIn}>
  <Text>Dashboard</Text>
</Show>
  • Conditional rendering
  • Returns null when false

<Repeat />

<Repeat n={3}>
  <Text>Line</Text>
</Repeat>
  • Repeats children n times
  • Internally uses fragments

Layout Helpers

The library provides basic layout primitives built on react-pdf:

  • Box
  • Flex
  • Stack
  • Page
  • Document
  • Text

These are thin wrappers with predictable props.

Example:

<Page size="A4" p="2cm">
  <Stack g="1cm">
    <Text>Title</Text>
    <Text>Content</Text>
  </Stack>
</Page>

Absolute Positioning

import { Absolute } from "@papack/pdf";

<Absolute top="2cm" left="2cm">
  <Text>Overlay</Text>
</Absolute>;
  • Maps directly to position: absolute
  • No layout engine involved

Styling

Shared style constants are provided:

  • font
  • color
  • size
  • space

Example:

font.size.lg;
font.weight.bold;

Font Registration

Use static imports (e.g. via bundler ?url):

import sourceRegular from "./assets/source-code-pro-regular.ttf?url";
import sourceItalic from "./assets/source-code-pro-italic.ttf?url";

Register Fonts

import { Font } from "@papack/pdf";

Font.register({
  family: family.mono,
  src: new URL(sourceRegular, import.meta.url).pathname,
  fontWeight: 400,
});

Font.register({
  family: family.mono,
  src: new URL(sourceItalic, import.meta.url).pathname,
  fontWeight: 400,
  fontStyle: "italic",
});
  • One Font.register call per weight/style
  • src must resolve to a filesystem path
  • fontWeight and fontStyle must match usage exactly

Usage

<Text style={{ fontFamily: family.mono, fontWeight: 400 }}>Code</Text>