Skip to content

Commit

Permalink
create canvas from directive
Browse files Browse the repository at this point in the history
  • Loading branch information
endorama committed May 25, 2017
1 parent ea8056c commit b83f912
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion example/partials/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@
<hr>

{{loading}}
<canvas id="pdf" class="rotate0"></canvas>
8 changes: 7 additions & 1 deletion src/angular-pdf.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export const NgPdf = ($window, $document, $log) => {
canvas.getContext('2d').setTransform(ratio, 0, 0, ratio, 0, 0);
return canvas;
};

const initCanvas = (element, canvas) => {
angular.element(canvas).addClass('rotate0');
element.append(canvas);
};

return {
restrict: 'E',
Expand All @@ -39,7 +44,8 @@ export const NgPdf = ($window, $document, $log) => {
let pageFit = attrs.scale === 'page-fit';
let scale = attrs.scale > 0 ? attrs.scale : 1;
let canvasid = attrs.canvasid || 'pdf-canvas';
let canvas = $document[0].getElementById(canvasid);
let canvas = $document[0].createElement('canvas');
initCanvas(element, canvas);
let creds = attrs.usecredentials;
debug = attrs.hasOwnProperty('debug') ? attrs.debug : false;

Expand Down

0 comments on commit b83f912

Please sign in to comment.