html4pdf vs @react-pdf/renderer

This is the most serious of the client side options, and the comparison is about duplication rather than quality: either you maintain one design or you maintain two.

The short answer

Use react-pdf when the document is small, stable, and worth building as its own component tree. Use a renderer when the PDF should be the same thing your users already see on screen.

What @react-pdf/renderer is

@react-pdf/renderer is a React renderer that outputs PDF primitives. You compose Document, Page, View and Text components, style them with a StyleSheet that supports a subset of flexbox, and get a real PDF with selectable text and vector graphics. It runs in the browser or on a server, with no browser engine involved.

Side by side

 @react-pdf/rendererhtml4pdf
What you writeIts components and StyleSheetThe HTML and CSS you already have
Layout engineIts own, a subset of flexboxChrome
Text qualityReal text and vectorsReal text and vectors
CSS supportA defined subset, no cascade, no gridEverything Chrome supports
Where it runsBrowser or server, in your processAn HTTPS call
Reusing your UINo, the document is built separatelyYes, render the component you already have
LanguagesReact onlyAny
CostFreeFrom $0.033 per document
Bundle sizeSignificant if it ships to the browserNothing in the bundle

Choose @react-pdf/renderer when

  • The document is a fixed, long-lived layout worth building once in its own components.
  • There must be no server call, for cost, privacy or offline reasons.
  • You want precise control over page breaks and repeating headers in code.
  • Your team is React everywhere and happy to own two trees.

Choose html4pdf when

  • The PDF should look like the page your users see, and that page already exists.
  • The design changes often, and keeping two implementations in step is the real cost.
  • You need CSS the subset does not cover: grid, pseudo elements, complex typography.
  • You do not want a PDF library in the client bundle.

See the code

The working example, in the language this decision is being made in.

@react-pdf/renderer: common questions

Does react-pdf produce real text?

Yes. Unlike the html2canvas approach, output is real text and vector graphics, so it can be selected, searched and printed properly.

Can react-pdf render my existing HTML?

No. It renders its own primitives. Existing markup and stylesheets have to be rebuilt as its components.

Does it support CSS grid?

No. Styling is a subset of flexbox with inline styles, and there is no cascade or selector system.

Can I run it on the server?

Yes, which keeps it out of your client bundle and is usually the better place for it.

Try it before you decide

New accounts get 10 free credits, no card. Send the HTML you already have and compare the output against whatever you are using now.

Get API key

Other comparisons