Skip to content

thepiyush-303/pdf-annotate.js

This branch is 2 commits ahead of Submitty/pdf-annotate.js:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

884d0bd · Jul 13, 2024
Feb 17, 2023
Jun 28, 2024
Jul 31, 2020
Jun 10, 2021
Jul 1, 2021
Apr 16, 2019
Jun 21, 2022
Sep 5, 2021
Jun 21, 2022
Sep 14, 2019
Jun 28, 2024
Jul 12, 2019
Jun 28, 2024
Apr 16, 2019
Jul 9, 2024
Sep 9, 2015
Mar 14, 2020
Jul 12, 2024
Jul 12, 2024
Feb 8, 2022
Mar 15, 2020
Mar 8, 2019
Mar 8, 2019
Mar 8, 2019

Repository files navigation

@submitty/pdf-annotate.js

Test codecov

Annotation layer for PDF.js.

Combined fork of archived instructure/pdf-annotate.js and deleted DynamicEnvironmentSystems/pdf-annotate.js. Under active development for usage within Submitty.

To report issues for pdf-annotate.js, please file them under the Submitty/Submitty repository.

Objectives

  • Provide a low level annotation layer for PDF.js.
  • Optional high level UI for managing annotations.
  • Agnostic of backend, just supply your own StoreAdapter to fetch/store data.
  • Prescribe annotation format.

Installation

npm install Submitty/pdf-annotate.js

Example

import pdfjsLib from 'pdfjs-dist/build/pdf';
import PDFJSAnnotate from 'pdfjs-annotate';

const { UI } = PDFJSAnnotate;
const VIEWER = document.getElementById('viewer');
const RENDER_OPTIONS = {
  documentId: 'MyPDF.pdf',
  pdfDocument: null,
  scale: 1,
  rotate: 0
};

pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdf.worker.js';
PDFJSAnnotate.setStoreAdapter(new PDFJSAnnotate.LocalStoreAdapter());

pdfjsLib.getDocument(RENDER_OPTIONS.documentId).promise.then((pdf) => {
  RENDER_OPTIONS.pdfDocument = pdf;
  VIEWER.appendChild(UI.createPage(1));
  UI.renderPage(1, RENDER_OPTIONS);
});

See /web for an example web client for annotating PDFs.

Documentation

View the docs.

Developing

# clone the repo
$ git clone https://github.com/Submitty/pdf-annotate.js.git
$ cd pdf-annotate.js

# intall dependencies
$ npm install

# start example server
$ npm start
$ open http://127.0.0.1:8080

# run tests
$ npm test

# lint the code
$ npm run lint

Building

Do not commit your built files when contributing. If on Windows, change the build script in package.json to webpack && SET MINIFY=1&webpack.

# switch to node v14 or earlier
$ nvm use 14

# build the dist files
$ npm run build

About

Annotation layer for pdf.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 92.0%
  • HTML 6.5%
  • Other 1.5%