Git Product home page Git Product logo

react-pdf-highlighter's Introduction

โ˜•๏ธ Buy me a coffee

Node CI

react-pdf-highlighter

react-pdf-highlighter is a React library that provides annotation experience for PDF documents on web. It is built on top of PDF.js by Mozilla. Text and rectangular highlights are supported. Highlight data format is independent of the viewport, making it suitable for saving on the server.

Example (Create React App)

For online example check https://agentcooper.github.io/react-pdf-highlighter/.

To run the example app locally:

npm install
npm start

While docs are in progress, feel free to check the source annotated with Flow type signatures.

Installation

npm install react-pdf-highlighter

See packages/example/src/App.js for React component API example.

Prior art

react-pdf and react-pdfjs only provide React wrappers for PDF.js and do not have built-in annotation functionality.

pdfjs-annotate does not provide text highlights out of the box.

PDF.js provides only viewer:

PDF.js is mainly written for reading PDF files, not editing them. Because of that we don't yet support adding any kind of annotations. We do however support rendering a number of annotation types for viewing.

See also:

FAQ

Can I get a new PDF with the highlights embedded into the document?

No, but pdf-annotation-service might be helpful for you.

Wasn't this named react-pdf-annotator at some point?

Yes, but people from https://www.pdfannotator.com/ asked me to rename, since they have a trademark for PDF Annotator.

I'm trying the demo with my PDF and it is not loading!

Please check the CORS headers on your url. It is required for the cross-domain request.

Compatibility

Works in Google Chrome, Safari 10+, Firefox 52+. Not tested in Internet Explorer.

Contributing

To publish a new version:

npx lerna version

cd ./packages/react-pdf-highlighter
npm publish

PDF.js worker thread

The default worker is an inline "fake" worker. To improve performance, either add the worker-loader (preferred) to your webpack config or use the inline loader syntax.

Webpack config example snippet

Use this if have your own config

{
  ...
  module: {
    rules: [
      {
        test: /\.worker\.js$/,
        use: 'worker-loader',
      },
      ...
    ]
  }
}

Inline Webpack-loader syntax

Use in Create React App projects

import PDFWorker from "worker-loader!pdfjs-dist/lib/pdf.worker";

import {setPdfWorker} from 'react-pdf-highlighter';

setPdfWorker(PDFWorker);
...

react-pdf-highlighter's People

Contributors

agentcooper avatar jsg2021 avatar albcunha avatar mapreal19 avatar z4m0 avatar dependabot[bot] avatar acco avatar fensterbank avatar amihay-hellofyllo avatar arpitbhalla avatar jinman avatar jonasgruenwald avatar serizawa-jp avatar steevn avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.