React components and hooks for the pdfrx_web canvas viewer. Start with the
all-in-one PdfrxViewerApp,
compose the supplied UI pieces, or build custom UI with headless hooks.
npm package · Live demo · API reference · Detailed guide
npm install @pdfrx/react react react-dom
import { PdfrxViewerApp } from '@pdfrx/react';
import '@pdfrx/react/styles.css';
export function App() {
return (
<PdfrxViewerApp
src="/manual.pdf"
wasmModulesUrl="/pdfium/"
style={{ height: '100dvh' }}
/>
);
}
Copy pdfium_worker.js and pdfium.wasm from
node_modules/@pdfrx/engine/assets/ into the public /pdfium/ directory.
Remote PDF URLs must allow browser CORS access.
Browser printing is supported on desktop platforms. On iOS/iPadOS the standard print button is omitted because WebKit cannot reliably isolate PDF pages from the surrounding viewer UI; use the save/download action instead.
The canvas background and the all-in-one app background are separate layers.
To reveal the embedding application's background through
PdfrxViewerApp,
make both transparent:
<PdfrxViewerApp
src="/manual.pdf"
wasmModulesUrl="/pdfium/"
backgroundColor="transparent"
style={{ height: '100dvh', background: 'transparent' }}
/>
backgroundColor="transparent" clears the viewer canvas around PDF pages.
The inline background override removes the default var(--pdfrx-bg) fill on
the .pdfrx-app wrapper; omitting it reveals that themed wrapper background,
not the application behind it.
PdfrxViewerApp:
ready-made toolbar, sidebar, search, forms, annotations, print, and save UI.PdfrxProvider
with PdfViewerSurface:
compose the supplied components into your own layout.usePdfNavigation,
usePdfZoom,
and usePdfSearch:
own the UI while reusing viewer state.PdfrxViewerApp
explains application-controlled open, page, and export operations.@pdfrx/colab for
synchronized multi-user editing.@pdfrx/engine ·
@pdfrx/viewer ·
@pdfrx/reactMIT
React bindings for the pdfrx canvas-based PDF viewer.
Three layers, pick the one that fits:
srcprop.@pdfrx/react/styles.cssfor their default look.All three need the engine's WASM assets: point
wasmModulesUrlat a directory holdingpdfium_worker.jsandpdfium.wasm(copy them fromnode_modules/@pdfrx/engine/assets/, or use the jsDelivr CDN).Example: All-in-one
Example: Composed