Introduction
The SDK is a React library for building PDF applications in the browser: viewers, editors, form fillers, and the tools in between. It is built around one idea: the SDK owns the document, and you own the UI.
The main component, Viewport, renders the pages and handles direct interaction with them (scrolling, zooming, selecting, typing, filling form fields). Everything around it, such as toolbars, sidebars, and shortcuts, is your own React code that drives the SDK through hooks: hooks that read document state re-render your components when that state changes, and hooks that return commands let you change the document.
Beta: the SDK is in beta, and the exports and their APIs may change freely between releases. Pin the exact package version and review the changes when updating.
Where to start
- Getting started: install the package from the private registry, set up
PdfProviders, load a document, and render theViewport. - Building a PDF application: how the main view, the toolbar, the sidebars, and the selection toolbar map to the SDK's API.
- Working with forms: read and fill form fields, and build a form sidebar.
- Programmatic editing: read and change document text from code, without user interaction.
- Theming and customization: attach your class names and styles to the SDK's elements, or replace them with your own components.
- Error handling and logging: the errors the SDK throws and the messages it logs.
Migration guides
- Migrating from pdf.js: replace
getDocument, canvas rendering, and thePDFViewercomponents withPdfProviders,Viewport, and hooks. - Migrating from Apryse WebViewer: rebuild the WebViewer UI as React components and move
instance.Corecalls to hooks. - Migrating from Nutrient Web SDK: replace
NutrientViewer.load, the instance API, and the built-in toolbar withPdfProviders,Viewport, and your own components. - Migrating from Foxit PDF SDK for Web: replace
PDFUIandPDFViewerwithViewport, and the viewer's states and events with hooks. - Migrating from Syncfusion PDF Viewer: replace
PdfViewerComponentand its injected modules withViewportand hooks. - Migrating from pdf-lib: move page, form, and text changes from pdf-lib calls to hooks, with the document visible and editable while you change it.
- Migrating from MuPDF.js: replace the pixmap render loop, widget calls, and the journal with
Viewportand hooks. - Migrating from PDFium: move a viewer built on
FPDF_RenderPageBitmapand the form-fill environment into the browser. - Migrating from Aspose.PDF for .NET: move what users see and edit from server-side
Documentcode into the browser, and keep the rest on your server. - Migrating from iText: move form filling, page changes, and stamping that users drive from iText on the server into the browser.
- Migrating from Ghostscript: replace server-rendered page images and thumbnails with
ViewportandPageCanvas.
API reference
Every component, hook, and constant exported by @sdk-pdf/react has its own page. See the API reference for the full list, grouped by area: components, document, viewport, pages, selection, and widgets.
Installation
npm install @sdk-pdf/reactThe package is distributed through our private registry; Getting started explains how to configure npm for the @sdk-pdf scope, and Project setup covers the stylesheet, client-only rendering, the canvas alias, and React Strict Mode.
React is the first supported framework. Vue, Angular, and Svelte packages are coming soon. Subscribe to the wishlist to get notified when yours ships.