TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

React pdfmake Reconciler

This package lets you create PDFs using pdfmake and React.

npm version


This package is available on NPM.

npm i react-pdfmake-reconciler


  • Write complex PDF in JSX. Render JSX into pdfmake content structure.
  • Utilize React features like:
    • Context. Note that outside React contexts do not penetrate into PDF renderer.
    • Components
    • Hooks
  • Working React update loop, (although it is unlikely to trigger user events inside PDF.), e.g.
    • async setState calls
    • useEffect call
  • TypeScript typing for pdfmake Components (<pdf-*> components)
  • React Developer Tools support
  • Styled API

React Developer Tools Demo

Running demo

pnpm i
pnpm dev


See /demo and tests for more extensive examples.

Simple examples

/// <reference types="react-pdfmake-reconciler/react-jsx" />

import { PdfRenderer } from "react-pdfmake-reconciler/PdfRenderer";

const { unmount } = PdfRenderer.render(
  <pdf-text bold>Hello World!</pdf-text>,
  (document) => console.log(document),

  content: {
    $__reactPdfMakeType: 'pdf-text',
    text: 'Hello World!',
    bold: true

// Call unmount to detach node tree.
import { PdfRenderer } from "react-pdfmake-reconciler/PdfRenderer";

const document = PdfRenderer.renderOnce(<pdf-text bold>Hello World!</pdf-text>);

PDF elements

Newly defined intrinsic elements by this package have the pdf- prefix. Roughly speaking, each type of pdfmake content object corresponds to one element type, where the property specifying the Content is mapped to the children prop. For example:

const pdfMakeContent = {
  text: "GitHub",
  link: "",

// is mapped to

const pdfNode = <pdf-text link="">GitHub</pdf-text>;

There are also virtual element types. For more information, read JSDocs in types for more information.

Document, Header, and Footer

You can easily define extra document definition props straight inside your JSX using <PdfDocument>. It is optional to put the body of the document inside this component.

Implemented using React Portals, you can define static/dynamic header and footer using <PdfHeader> and <PdfFooter>.

These components can appear anywhere within your JSX structure, although you may follow this convention for a better looking structure:

import { PdfDocument, PdfHeader, PdfFooter } from "react-pdfmake-reconciler";

const pdfNode = (
  <PdfDocument orientation="landscape">
    {/* Example static header */}
    <PdfHeader>This is a header</PdfHeader>
    {/* Example dynmaic footer */}
      {(pageNumber, pageCount) => (
          Page {pageNumber} / {pageCount}


<PdfPreview> provides an easy way to render your React pdfmake Reconciler JSX in the browser. You can also debug your PDF JSX using the React Developer Tools browser extension.

import { FC, StrictMode } from "react";
import { PdfPreview } from "react-pdfmake-reconciler";

const App: FC = () => (
      {/* Optional */}
        {/* Only use components that resolves to pdf-* components from here on out. DOM elements won't work. */}
        <pdf-text>Hello World!</pdf-text>

Package Sidebar


npm i react-pdfmake-reconciler

Weekly Downloads






Unpacked Size

30.6 kB

Total Files


Last publish


  • danvim