DEV Community

Cover image for How to Embed and Edit PDFs in React Using the React PDF Viewer
Zahra Sandra Nasaka for Syncfusion, Inc.

Posted on • Originally published at syncfusion.com on

How to Embed and Edit PDFs in React Using the React PDF Viewer

TL;DR: Embedding an editable PDF in React can be challenging because most viewers lack interactivity. This guide shows how to integrate a PDF viewer with editing, annotations, and form fields directly in your React app.

Have you ever tried embedding editable PDFs in React, only to discover that most viewers offer little to no interactivity? These days, we manage documents directly in the browser, reviewing contracts, filling out forms, or sharing feedback, and expect a smooth and responsive experience. Unfortunatly when it comes to PDFs, the experience often falls short.

Most React-based PDF viewers provide only the basics: they display the document, and that’s it. There’s no option to highlight text, add comments, or interact with form fields. Developers also face challenges like static rendering, limited annotation tools, poor performance with large files, and inflexible UI customization.

That’s where Syncfusion®’s React PDF Viewer makes a real difference. It supports editing, annotation, form-filling, and design capabilities directly within your app, without requiring extra plugins or downloads.

In this blog, we’ll show you how to embed an editable PDF in React using Syncfusion PDF Viewer and explore powerful features like annotations, the form designer, and page organization.

Steps to integrate a Syncfusion PDF Viewer in React

Step 1: Initialize your React project

First, create a new React application using Create React App. Open your terminal and run.

npx create-react-app syncfusion-pdf-viewer
cd syncfusion-pdf-viewer
Enter fullscreen mode Exit fullscreen mode

This sets up the base project where you’ll integrate the PDF viewer.

Step 2: Install Syncfusion React PDF Viewer

Next, install the Syncfusion PDF Viewer package via npm.

npm install @syncfusion/ej2-react-pdfviewer
Enter fullscreen mode Exit fullscreen mode

This adds all the necessary components and dependencies for rendering and editing PDFs.

Step 3: Import required styles

To ensure proper styling, import the required CSS files into your index.css.

@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
@import "../node_modules/@syncfusion/ej2-pdfviewer/styles/material.css";
Enter fullscreen mode Exit fullscreen mode

These styles ensure the viewer and its toolbar look consistent with the Material theme.

Step 4: Add the PDF Viewer component

Finally, integrate the Syncfusion PDF Viewer into your React app by adding the following code.

import { 
    PdfViewerComponent,
    Toolbar,
    Magnification,
    Navigation,
    LinkAnnotation,
    BookmarkView,
    ThumbnailView,
    Print,
    TextSelection,
    Annotation,
    TextSearch,
    FormFields,
    FormDesigner,
    Inject\
} from '@syncfusion/ej2-react-pdfviewer';

function App() {
    return (
        <div>
            {/* Render the PDF Viewer */}
            <PdfViewerComponent
                id="container"
                documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
                resourceUrl="https://cdn.syncfusion.com/ej2/31.2.7/dist/ej2-pdfviewer-lib"
                style={{ 'height': '640px' }}
            >

                <Inject 
                    services={[
                        Toolbar,
                        Magnification,
                        Navigation,
                        Annotation,
                        LinkAnnotation,
                        BookmarkView,
                        ThumbnailView,
                        Print,
                        TextSelection,
                        TextSearch,
                        FormFields,
                        FormDesigner
                    ]}
                />
            </PdfViewerComponent>
        </div>
    );
}
Enter fullscreen mode Exit fullscreen mode

Note: For a complete working example of loading a PDF in the React PDF Viewer, check out our GitHub repository.

Experience seamless editable PDFs in React

Syncfusion’s React PDF Viewer delivers a complete solution for embedding editable PDFs with advanced interactivity. From smooth navigation to rich annotations, organized pages, and dynamic form design, it brings powerful document editing tools directly into your React application.

Below are the key features that make this viewer ideal for modern web applications:

Organize pages

A robust Page Organizer allows users to rotate, reorder, insert, delete, duplicate, and import pages through an intuitive UI. It supports drag-and-drop functionality and thumbnail previews with magnification. The organizer’s behavior is fully customizable via the pageOrganizerSettings API, and dialog interactions can also be controlled programmatically.

Seamless PDF editing and page organization in React


Seamless PDF editing and page organization in React

Note: For a detailed guide on organizing pages in the PDF Viewer, check the official documentation.

Annotations and comments

Advanced annotation tools enable users to interact with documents seamlessly. Supported features include:

  • Text markups like highlight, underline, strikethrough, squiggly
  • Shapes and stamps
  • Ink (hand-drawn notes)
  • Calibration tools
  • Free text and sticky notes

Annotations are fully interactive; users can add, move, resize, customize properties, or delete them easily. Developers can configure annotation tools via the toolbar or programmatically and use event hooks to save or export annotations for further processing.

Advanced PDF annotations and comments in React


Advanced PDF annotations and comments in React

Note: For detailed guidance on annotation types, customization options, and implementation steps, refer to the UG documentation.

Form filling and designer

An editable PDF viewer in React should make form creation and interaction effortless. With built-in form designer tools and programmatic APIs, developers can dynamically add fields such as text boxes, password inputs, checkboxes, radio buttons, dropdowns, list boxes, and signature fields.

Users can design forms interactively using a drag-and-drop UI. This flexibility makes it ideal for both predefined form templates and scenarios requiring dynamic form generation.

Effortless PDF form filling and design in React


Effortless PDF form filling and design in React

Note: For detailed configuration and implementation steps, refer to the official form designer documentation.

Interactive PDF navigation

Smooth navigation is essential for a great user experience. Key navigation features include:

  • Page navigation: Allows users to jump to the first, last, previous, or next page using a page number box and total count. Enable via enableNavigation
  • Bookmark navigation: Allows quick access to key sections using predefined bookmarks. Toggle using the enableBookmark
  • Thumbnail navigation – Displays mini page previews in a side panel for visual navigation. Enable using enableThumbnail

Explore all the interactive PDF navigation options, including bookmarks, hyperlinks, thumbnails, and page navigation in the official documentation.

Smooth and interactive PDF navigation in React


Smooth and interactive PDF navigation in React

Real-world benefits and use cases

When choosing a PDF viewer for your React application, it’s important to consider how it improves both user experience and developer productivity. Syncfusion’s React PDF Viewer delivers on both fronts:

  • Enhanced user experience: Annotate, design forms, and add comments directly within PDFs in your React application, no external tools required.
  • Developer-friendly: Built-in UI components and APIs reduce the need for custom logic.
  • Optimized performance: Large PDFs load quickly with on-demand page rendering and efficient resource handling, ensuring smooth navigation and editing.

Conclusion

Embedding editable PDFs in React applications often presents challenges, including limited annotation support, form editing constraints, and performance issues. Traditional PDF components often lack the flexibility and interactivity that modern users expect, making it challenging to deliver a seamless document experience.

Syncfusion’s React PDF Viewer addresses these problems with powerful features, including annotation tools, a built-in form designer, efficient page organization, and high-speed rendering. Developers benefit from easy integration and customizable UI, while users enjoy smooth, in-document editing and navigation. To explore its full potential, check out the official documentation, live demos, and start your free trial today.

Syncfusion’s PDF Viewer is also available across multiple platforms, including Blazor, Angular, ASP.NET Core *, * ASP.NET MVC, .NET MAUI, JavaScript, Vue, WPF, WinForms, Flutter, and Document SDK libraries.

If you’re a Syncfusion user, you can download the setup from the license and downloads page. Otherwise, you can download a free 30-day trial.

You can also contact us through our support forum, support portal, or feedback portal for queries. We are always happy to assist you!

Related blog

This article was originally published at Syncfusion.com.

Top comments (0)