🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

react-custom-pdf-highlighter

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-custom-pdf-highlighter

Set of React components for PDF annotation

0.0.2-alpha4
latest
Source
npm
Version published
Weekly downloads
3
-72.73%
Maintainers
1
Weekly downloads
 
Created
Source

react-custom-pdf-highlighter

react-custom-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.

Install


npm i react-custom-pdf-highlighter

or

yarn add react-custom-pdf-highlighter

Usage

import  { PopupHighlighter } from 'react-custom-pdf-highlighter';

// Inside of a component's render() method:
render() {
  return (
  <PopupHighlighter 
    features={{ width: 1000, height: 700, top: 100, left: 100 }}
    center=false  // You need to explicitly say "false" for "top" and "left" to work!!
    title='PDF Viewer' // default PDF Viewer
    searchObj=searchObj
    pdfUrl= URL  // URL = pdf_url
    mark=true // true to highlight & default true
/>
  );
}
import  { CustomHighlighter } from 'react-custom-pdf-highlighter';

// Inside of a component's render() method:
render() {
  return (
    <CustomHighlighter
        searchObj=searchObj
        pdfUrl= URL  // URL = pdf_url
        mark=true // true to highlight & default true
    />
  );
}

DEFAULT - SearchObject

searchObj: {
    content: { "text": '' }, // default empty string - required filed
    position: {
        "boundingRect": { "x1": 30, "y1": 30, "x2": 30, "y2": 30, "width": pdf_width || 612, "height": pdf_height || 792 },
        "rects": [{ "x1": 30, "y1": 30, "x2": 30, "y2": 30, "width": pdf_width || 612, "height": pdf_height || 792 }],
        "pageNumber": 1 // default 1
   }
    comment: {
        "text": "",
        "emoji": ""
    }
}

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:

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.

Keywords

custom-react-pdf-highlighter

FAQs

Package last updated on 07 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts