npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@recogito/pdf-annotator

v4.0.0

Published

PDF annotation in the browser, using PDF.js and the Recogito Text Annotator

Downloads

1,422

Readme

Recogito PDF Annotator

A JavaScript library for PDF annotation, using PDF.js and the Recogito Text Annotator.

Also available: React wrapper

Animated screenshot of the Recogito PDF Annotator

Installation

npm install @recogito/pdf-annotator

Quick Start

import { createPDFAnnotator } from '@recogito/pdf-annotator';

var anno = await createPDFAnnotator(
  document.getElementById('container');, 
  'compressed.tracemonkey-pldi-09.pdf'
);

// Load annotations from a file
anno.loadAnnotations('annotations.json');

// Listen to user events
anno.on('createAnnotation', annotation => {
  console.log('new annotation', annotation);
});     

Configuration Options

const anno = createPDFAnnotator(element, url, options);

| Option | Type | Default | Description | |--------|------|---------|-------------| | annotatingEnabled | boolean | true | Enable or disable interactive creation of new annotations. | | dismissOnNotAnnotatable | 'NEVER' \| 'ALWAYS' \| function | 'NEVER' | Controls whether the current selection is dismissed when clicking outside of annotatable content. | | mergeHighlights | object | undefined | Merge adjacent highlights. Options: horizontalTolerance and verticalTolerance (in pixels) | | selectionMode | 'shortest' \| 'all' | 'shortest' | When the user selects overlapping annotations: select all or only the shortest. | | style | HighlightStyleExpression | undefined | Custom styling function for highlights. | | user | User | anonymous guest | Current user information, automatically added to created or updated annotations. |

Annotator API

Properties

currentScale: number

The current numeric scale value of the PDF viewer.

console.log(anno.currentScale);

currentScaleValue: string

The current scale setting value of the PDF viewer.

console.log(anno.currentScaleValue); // e.g. 'page-fit'

Methods

The PDF annotator supports all the API methods of the underlying text annotator instance. The following additional methods are available:

setScale(size: PDFScale | number): void

Sets the PDF viewer scale.

anno.setScale(2);
anno.setScale('page-fit');

zoomIn(percentage? number): void

Zoom the PDF viewer by a given percentage (default: 10).

anno.zoomIn();

zoomOut(percentage? number): void

Zoom the PDF viewer out by a given percentage (default: 10).

anno.zoomOut();

Events

The PDF annotator supports all the events of the underlying text annotator instance.

Annotation Format

The PDF annotator adds additional properties to the annotation target selector.

{ 
  "id": "cd18fb18-b0e9-44f4-a11d-39a35f830fb4",
  "bodies": [],
  "target": {
    "selector": [{
      "quote": "We present a trace-based compilation technique",
      "start": 3589,
      "end": 3635,
      "pageNumber": 1,
      "quadpoints": [
        328.95,
        276.11,
        510.17,
        276.11,
        328.95,
        286.55,
        510.17,
        286.55
      ]
    }],
    "created": "2025-09-30T10:28:25.987Z",
    "updated": "2025-09-30T10:28:27.561Z"
  }
}
  • pageNumber - the PDF page number where the annotation is located.

  • quadPoints - the bounding box rectangle(s) of the annotation, in PDF quadpoint format.

Annotation Styling

The PDF annotator supports the same styling properties as the text annotator.

const anno = createPDFAnnotator(element, url, {
  style: (annotation, state, z) => {
    const hasTag = annotation.bodies.some(b => b.purpose === 'tagging');

    return {
      fill: hasTag ? '#ffeb3b' : '#bbdefb',
      fillOpacity: state.hovered ? 0.35 : 0.2,
      underlineColor: hasTag ? '#f57f17' : undefined,
      underlineThickness: 1
    }
  }
});

License

The Recogito Text Annotator is licensed under the BSD 3-Clause license.