An AngularJS directive to display PDFs
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
dist Updated the minified file Mar 24, 2017
src Fixed a bug in PdfCtrl Mar 14, 2017
.bowerrc first commit Oct 27, 2014
.gitignore Added .idea to gitignore Mar 10, 2017
LICENSE Initial commit Oct 27, 2014
bower.json v0.2.13 release Mar 24, 2017
gulpfile.js make toolbar optional and updated readme Oct 27, 2014
package.json v0.2.13 release Mar 24, 2017 Maintained again Mar 9, 2017

Angular PDF Viewer

An AngularJS directive to display PDFs. DEMO


  1. AngularJS
  2. PDFJS


  1. bower install angular-pdf-viewer

  2. Include the path to the lib, AngularJS and PDFJS:

<script src="bower_components/pdfjs-dist/build/pdf.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-pdf-viewer/dist/angular-pdf-viewer.min.js"></script>
  1. Include the lib as a dependency in your angular app:
var app = angular.module('App', ['pdf']);


The URL, request headers, scale and delegate-handle can be set using the attributes:

    headers="{ 'x-you-know-whats-awesome': 'EVERYTHING' }"></pdf-viewer>

Delegate Service (pdfDelegate)

The pdfDelegate service allows you to access and control individual instances of a directive. This allows us to have multiple instances of the same directive in the same controller.

Inject the pdfDelegate service into your controller. You can then fetch an instance using it's delegate handle and call methods on it:


The following methods are available to the delegate:

  • prev
  • next
  • zoomIn(amount) default amount = 0.2
  • zoomOut(amount) default amount = 0.2
  • zoomTo(amount)
  • rotate (clockwise by 90 degrees)
  • getPageCount
  • getCurrentPage
  • goToPage(pageNumber)
  • load

Change the PDF File

In order to replace the active PDF with another one, you can call the load method of the delegate. For example:



Run npm install && bower install to install all dependencies. And then gulp dev to start a local server. The example will now be available at localhost:3000/src


The default toolbar can be shown or hidden using the show-toolbar attribute. Since the PDF can be easily controlled using the delegate service it's quite trivial to build a custom toolbar. Or place the toolbar on a separate scope.

Similar projects

  1. angularjs-pdf
  2. ng-pdfviewer


PDF examples used are Relativity: The Special and General Theory by Albert Einstein as kindly organized and made available free by Project Gutenberg. And the This is Material Design by Google.