Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/angular-pdf.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ export const NgPdf = ($window, $document, $log) => {
let renderTask = null;
let pdfLoaderTask = null;
let debug = false;
let canvas = null;
let url = scope.pdfUrl;
let httpHeaders = scope.httpHeaders;
let pdfDoc = null;
let pageToDisplay = isFinite(attrs.page) ? parseInt(attrs.page) : 1;
let pageFit = attrs.scale === 'page-fit';
let limitHeight = attrs.limitcanvasheight === '1';
let scale = attrs.scale > 0 ? attrs.scale : 1;
let canvas = $document[0].createElement('canvas');

if (attrs.hasOwnProperty('canvasid')) {
canvas = $document[0].getElementById(attrs.canvasid);
} else {
canvas = $document[0].createElement('canvas');
}
initCanvas(element, canvas);
let creds = attrs.usecredentials;
debug = attrs.hasOwnProperty('debug') ? attrs.debug : false;
Expand Down
4 changes: 2 additions & 2 deletions test/spec/ngPdfSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('ngPdf', function() {
var $document = _$document_;
$scope = $rootScope.$new();
// Compile a piece of HTML containing the directive
var html = '<ng-pdf template-url="partials/viewer.html" canvasid="pdf" scale="page-fit" page=13></ng-pdf>';
var html = '<ng-pdf template-url="partials/viewer.html" scale="page-fit" page=13></ng-pdf>';
var elmnt = angular.element(html);
$document.find('body').append(elmnt);
element = $compile(elmnt)($scope);
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('ngPdf protected', function() {
var $document = _$document_;
$scope = $rootScope.$new();
// Compile a piece of HTML containing the directive
var html = '<ng-pdf template-url="partials/viewer.html" canvasid="pdf" scale="page-fit" page=13></ng-pdf>';
var html = '<ng-pdf template-url="partials/viewer.html" scale="page-fit" page=13></ng-pdf>';
var elmnt = angular.element(html);
$document.find('body').append(elmnt);
element = $compile(elmnt)($scope);
Expand Down