Skip to content
REACT TO PDF

React to PDF — export components without a second template

Client-side React-to-PDF libraries screenshot the DOM and hand you a blurry image in a PDF wrapper. RenderKit renders the component server-side through Chromium's print pipeline, so the text stays selectable and the pagination is real.

The common browser recipe is html2canvas plus jsPDF: rasterise the DOM to a canvas, paste the canvas into a PDF. It works until someone tries to select the text, search the document, or print a table that spans three pages — because the output is a picture of a page, not a page.

What server-side rendering changes

  • Text stays selectable and searchable — it is typeset, not photographed
  • Page breaks obey break-inside and break-after instead of slicing mid-row
  • Running headers and footers with real page numbers
  • Output is identical across browsers, because your users' browsers are not involved
  • Fonts resolve server-side, so a missing local font cannot silently change the layout

Two ways to do it

Send the component directly with jsx, or point the API at a route your app already renders. The first keeps everything in one call; the second is useful when the page needs your session or your database.

export.ts
import { RenderKit } from "renderkit-sdk";
const rk = new RenderKit(process.env.RENDERKIT_API_KEY);

// 1. Component + props — nothing else to host
const a = await rk.pdf({
  jsx: { component: "Report", props: { quarter: "Q3", revenue: 128400 } },
  format: "A4",
  margin: { top: "18mm", bottom: "18mm" },
});

// 2. Or an existing route in your app
const b = await rk.pdf({
  url: "https://app.example.com/reports/2026-q3?print=1",
  wait_until: "networkidle",
  print_background: true,
});

Making the CSS behave

Print is a different medium and the browser treats it as one. A @media print block that hides navigation, sets break-inside: avoid on cards and table rows, and switches to physical units for margins gets you most of the way. Backgrounds need print_background: true — Chromium drops them by default.

More

JSX to PDF covers the component-native path in depth. See also React PDF invoices, HTML to PDF in React, and the full HTML to PDF API.

Common questions

Send the component name and props to /v1/pdf as jsx, or point the API at a URL your app renders. RenderKit renders it server-side with print CSS and returns a signed PDF URL.

html2canvas rasterises the DOM at screen resolution, so the PDF contains an image rather than text. Printing through Chromium typesets the document instead, which keeps text sharp at any zoom and selectable.

Yes. The component renders in a real browser, so Tailwind, CSS modules, styled-components, and @media print rules all apply exactly as they do on screen.

Yes — running headers and footers support page counters, so multi-page exports get 'Page X of Y' without you paginating manually.

Ship your first render in 60 seconds.

500 free renders to start. No card. Cancel by ignoring it.

Get your free key$npm i renderkit-sdk