Powered by react-pdf-highlighter-plus

Modern
PDF Annotation
for React

A feature-rich, headless PDF viewer and annotation library built on PDF.js. Highlight text, add notes, draw shapes, embed images, and export annotated PDFs. All processing happens in the browser.

6+
Annotation Types
100%
Client-Side
MIT
Licensed
TS
TypeScript

Everything you need for PDF annotations

A comprehensive set of annotation tools built for modern React applications.

Text Highlighting

Select and highlight text passages with customizable colors. Positions stored in viewport-independent coordinates.

Freetext Notes

Create draggable, editable sticky notes with styling options. Click to edit, drag to reposition.

Images & Signatures

Upload images or draw signatures with mouse/touch. Drag to reposition, resize with aspect ratio preservation.

Freehand Drawing

Draw directly on PDFs with customizable stroke color and width. Stored as PNG for export compatibility.

Shape Annotations

Add rectangles, circles, and arrows. Hold Alt while dragging for area selection on non-text content.

PDF Export

Export annotated documents with all highlights permanently embedded. Progress callback included.

Quick Installation

Get started in minutes with npm or yarn

1. Install the package

npm install react-pdf-highlighter-plus

2. Import the styles

import "react-pdf-highlighter-plus/style/style.css";

3. Basic usage example

import {
  PdfLoader,
  PdfHighlighter,
  TextHighlight,
  AreaHighlight,
  useHighlightContainerContext,
} from "react-pdf-highlighter-plus";

function App() {
  const [highlights, setHighlights] = useState([]);

  return (
    <PdfLoader document="https://example.com/doc.pdf">
      {(pdfDocument) => (
        <PdfHighlighter
          pdfDocument={pdfDocument}
          highlights={highlights}
          enableAreaSelection={(e) => e.altKey}
        >
          <HighlightContainer />
        </PdfHighlighter>
      )}
    </PdfLoader>
  );
}

Advanced Capabilities

Full Zoom Support

Zoom in/out while maintaining annotation positions with viewport-independent coordinate storage.

Fully Customizable

Exposed styling on all components. Extend the Highlight interface with custom properties.

Draggable Elements

Notes, images, and signatures can be repositioned by dragging. Toolbar appears on hover.

TypeScript First

Full TypeScript support with comprehensive type definitions for all components and utilities.

Export Annotated PDFs

Embed all annotations permanently into downloadable PDF files. Supports text highlights, area highlights, freetext notes, images, signatures, and drawings.

import { exportPdf } from "react-pdf-highlighter-plus";

const handleExport = async () => {
  const pdfBytes = await exportPdf(pdfUrl, highlights, {
    textHighlightColor: "rgba(255, 226, 143, 0.5)",
    onProgress: (current, total) =>
      console.log(`${current}/${total} pages`),
  });

  const blob = new Blob([pdfBytes], { type: "application/pdf" });
  const url = URL.createObjectURL(blob);
  // Download the file...
};

Why react-pdf-highlighter-plus?

Fully Open Source

MIT licensed and free to use in personal and commercial projects. No strings attached.

Modern Stack

Built with the latest React, TypeScript, and PDF.js for optimal performance and developer experience.

Privacy First

All processing happens in the browser. Your documents never leave your device.

Built with
React 19
TypeScript
PDF.js
Tailwind CSS
shadcn/ui
Zustand

Get started with:

npm install react-pdf-highlighter-plus

Component Architecture

PdfLoader
Creates container to load PDF documents
PdfHighlighter
Provides viewer with event listeners
HighlightContainer
User-defined, rendered per highlight
TextHighlight
AreaHighlight
FreetextHighlight
ImageHighlight
DrawingHighlight

Context Hooks

usePdfHighlighterContext()

Viewer utilities: scrollToHighlight, setTip, getCurrentSelection

useHighlightContainerContext()

Per-highlight: highlight object, viewportToScaled, screenshot

Ready to get started?

Experience all the annotation features with our interactive demo. Upload your own PDF or use our sample document.

Launch Demo