A minimal pdf viewing directive for Angular.
There are plenty of other PDFJS Angular directives already available. This one is different:
- All pages of the requested pdf are rendered, there is no pagination widget.
- There are only a few attributes to think about:
url
,width
, andclass
. - Everything is contained within the
<pdf-viewer>
element, there is no need to create and target external<canvas>
elements.
##Dependencies
-
Install the package
bower install ng-pdf-viewer
-
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>
-
Include the directive as a dependency:
var app = angular.module('App', ['pdf-viewer']);
-
Create a
<pdf-viewer>
element<pdf-viewer url="path/to/pdf.pdf"></pdf-viewer>
###Options
-
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>
-
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>
-
class
applies CSS class(es) to the PDF canvas<pdf-viewer url="path/to/pdf.pdf" class="dark-border"></pdf-viewer>
##Similar projects
(C) Parris Varney 2015, released under an MIT license