/ng-pdf-viewer

A light weight PDF viewing directive for AngularJs

Primary LanguageJavaScript

ng-pdf-viewer

A minimal pdf viewing directive for Angular.

Why?

There are plenty of other PDFJS Angular directives already available. This one is different:

  1. All pages of the requested pdf are rendered, there is no pagination widget.
  2. There are only a few attributes to think about: url, width, and class.
  3. Everything is contained within the <pdf-viewer> element, there is no need to create and target external <canvas> elements.

##Dependencies

  1. AngularJS
  2. PDFJS

Usage

  1. Install the package

    bower install ng-pdf-viewer
  2. Include the pdf.js and ng-pdf-viewer.js source files

    <script src="bower_components/pdfjs-dist/build/pdf.combined.js"></script>
    <script src="bower_components/ng-pdf-viewer/src/ng-pdf-viewer.min.js"></script>
  3. Include the directive as a dependency:

    var app = angular.module('App', ['pdf-viewer']);
  4. Create a <pdf-viewer> element

    <pdf-viewer url="path/to/pdf.pdf"></pdf-viewer>

###Options

  1. url (required), the path to the pdf. This can an be relative or absolute. Note - CORS is required for external PDFs.

    <pdf-viewer url="http://www.example.com/path/to/cors-enabled/pdf"></pdf-viewer>
  2. width (optional) sets the width of the viewport, defaults to the pdf width. The height is automatically derived from the width.

    <pdf-viewer url="path/to/pdf.pdf" width="500"></pdf-viewer>
  3. class applies CSS class(es) to the PDF canvas

    <pdf-viewer url="path/to/pdf.pdf" class="dark-border"></pdf-viewer>

##Similar projects

  1. angular-pdf
  2. angular-pdf-viewer
  3. ng-pdfviewer

License

(C) Parris Varney 2015, released under an MIT license