Coder Social home page Coder Social logo

annotate-pdf.js's Introduction

PDF.js viewer with Hypothesis

A web PDF viewer (PDF.js) with Hypothesis added.

This is a copy of Mozilla's PDF.js viewer with Hypothesis annotation tools added.

When to use this project

If you want to embed or link to a PDF on your site with annotation using Hypothesis enabled, the easiest way is using our proxy server: https://via.hypothes.is/<PDF URL>.

For example, to embed a PDF on your site using Hypothesis, you can add an HTML snippet such as the following to your page:

<iframe width="800" height="600" src="https://via.hypothes.is/https://publisher.com/article.pdf">
</iframe>

There are situations where the proxy server may not be suitable:

  • If the PDF is not publicly accessible (for example, it is behind a paywall, requires a login or is on a corporate intranet)
  • If you want to make customizations to the PDF viewer (for example, to add custom analytics scripts or change the configuration of the Hypothesis client)
  • If you are running your own instance of the Hypothesis annotation server

If any of the above apply, this project may be useful.

To use it, add the files from this repository to your site and embed or link to viewer/web/viewer.html?file=<PDF URL>.

Usage

Clone this repository, then run:

# Navigate to the project's root directory
cd pdf.js-hypothes.is

# If using Python 2, start a simple HTTP server...
python -m SimpleHTTPServer
# ...or if using Python 3
python -m http.server 8000

# Then run the command below or navigate to the URL in your browser
open http://localhost:8000/viewer/web/viewer.html

The default PDF should render and the Hypothesis annotation tools will appear when you select text.

Viewing Your Own PDFs

The viewer/web/viewer.html file supports a file query parameter which specifies the URL of a PDF to load. This PDF must either be hosted on the same origin or be served with appropriate headers that allow it to be loaded from the viewer's origin.

For example:

http://localhost:8000/web/viewer.html?file=%2Fyourpdf.pdf

%2F is the URL escaped form of /--so this assumes you have a yourpdf.pdf file hosted at http://localhost:8000/

License

The PDF.js files in viewer/ are licensed under the Apache License 2.0.

The Hypothesis annotation tools are loaded from the public service at https://hypothes.is, so there's no additional licensing needed. See the hypothesis/h project if you'd like to host your own.

annotate-pdf.js's People

Contributors

bigbluehat avatar cgorringe avatar cvzakharchenko avatar lyzadanger avatar robertknight avatar sehcheese avatar

Watchers

 avatar  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.