From 5e160064015c14b9d18dd680713c0685972effc5 Mon Sep 17 00:00:00 2001 From: Denny Biasiolli Date: Mon, 20 Feb 2017 20:52:44 +0100 Subject: [PATCH] Release v1.5.1 --- bower.json | 2 +- dist/angular-pdf.js | 2 +- dist/angular-pdf.min.js | 2 +- example/js/directives/angular-pdf.min.js | 2 +- package.json | 2 +- readme.md | 2 +- src/angular-pdf.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index 6636351..2b68cad 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-pdf", - "version": "1.5.0", + "version": "1.5.1", "description": "An Angularjs directive to display PDF in the browser with PDFJS.", "main": "./dist/angular-pdf.js", "license": "MIT", diff --git a/dist/angular-pdf.js b/dist/angular-pdf.js index ecdb98f..bb8cabc 100644 --- a/dist/angular-pdf.js +++ b/dist/angular-pdf.js @@ -1,4 +1,4 @@ -/*! Angular-PDF Version: 1.5.0 | Released under an MIT license */ +/*! Angular-PDF Version: 1.5.1 | Released under an MIT license */ (function() { 'use strict'; diff --git a/dist/angular-pdf.min.js b/dist/angular-pdf.min.js index 73d4123..ae6a771 100644 --- a/dist/angular-pdf.min.js +++ b/dist/angular-pdf.min.js @@ -1,2 +1,2 @@ -/*! Angular-PDF Version: 1.5.0 | Released under an MIT license */ +/*! Angular-PDF Version: 1.5.1 | Released under an MIT license */ !function(){"use strict";angular.module("pdf",[]).directive("ngPdf",["$window",function($window){var renderTask=null,pdfLoaderTask=null,debug=!1,backingScale=function(canvas){var ctx=canvas.getContext("2d"),dpr=window.devicePixelRatio||1,bsr=ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.oBackingStorePixelRatio||ctx.backingStorePixelRatio||1;return dpr/bsr},setCanvasDimensions=function(canvas,w,h){var ratio=backingScale(canvas);return canvas.width=Math.floor(w*ratio),canvas.height=Math.floor(h*ratio),canvas.style.width=Math.floor(w)+"px",canvas.style.height=Math.floor(h)+"px",canvas.getContext("2d").setTransform(ratio,0,0,ratio,0,0),canvas};return{restrict:"E",templateUrl:function(element,attr){return attr.templateUrl?attr.templateUrl:"partials/viewer.html"},link:function(scope,element,attrs){function clearCanvas(){ctx&&ctx.clearRect(0,0,canvas.width,canvas.height)}function renderPDF(){clearCanvas();var params={url:url,withCredentials:creds};httpHeaders&&(params.httpHeaders=httpHeaders),url&&url.length&&(pdfLoaderTask=PDFJS.getDocument(params),pdfLoaderTask.onProgress=scope.onProgress,pdfLoaderTask.onPassword=scope.onPassword,pdfLoaderTask.then(function(_pdfDoc){"function"==typeof scope.onLoad&&scope.onLoad(),pdfDoc=_pdfDoc,scope.renderPage(scope.pageToDisplay),scope.$apply(function(){scope.pageCount=_pdfDoc.numPages})},function(error){error&&"function"==typeof scope.onError&&scope.onError(error)}))}element.css("display","block");var url=scope.pdfUrl,httpHeaders=scope.httpHeaders,pdfDoc=null,pageToDisplay=isFinite(attrs.page)?parseInt(attrs.page):1,pageFit="page-fit"===attrs.scale,scale=attrs.scale>0?attrs.scale:1,canvasid=attrs.canvasid||"pdf-canvas",canvas=document.getElementById(canvasid);debug=!!attrs.hasOwnProperty("debug")&&attrs.debug;var creds=attrs.usecredentials,ctx=canvas.getContext("2d"),windowEl=angular.element($window);windowEl.on("scroll",function(){scope.$apply(function(){scope.scroll=windowEl[0].scrollY})}),PDFJS.disableWorker=!0,scope.pageNum=pageToDisplay,scope.renderPage=function(num){renderTask&&renderTask._internalRenderTask.cancel(),pdfDoc.getPage(num).then(function(page){var viewport,pageWidthScale,renderContext;if(pageFit){viewport=page.getViewport(1);var clientRect=element[0].getBoundingClientRect();pageWidthScale=clientRect.width/viewport.width,scale=pageWidthScale}viewport=page.getViewport(scale),setCanvasDimensions(canvas,viewport.width,viewport.height),renderContext={canvasContext:ctx,viewport:viewport},renderTask=page.render(renderContext),renderTask.promise.then(function(){"function"==typeof scope.onPageRender&&scope.onPageRender()}).catch(function(reason){console.log(reason)})})},scope.goPrevious=function(){scope.pageToDisplay<=1||(scope.pageToDisplay=parseInt(scope.pageToDisplay)-1,scope.pageNum=scope.pageToDisplay)},scope.goNext=function(){scope.pageToDisplay>=pdfDoc.numPages||(scope.pageToDisplay=parseInt(scope.pageToDisplay)+1,scope.pageNum=scope.pageToDisplay)},scope.zoomIn=function(){return pageFit=!1,scale=parseFloat(scale)+.2,scope.renderPage(scope.pageToDisplay),scale},scope.zoomOut=function(){return pageFit=!1,scale=parseFloat(scale)-.2,scope.renderPage(scope.pageToDisplay),scale},scope.fit=function(){pageFit=!0,scope.renderPage(scope.pageToDisplay)},scope.changePage=function(){scope.renderPage(scope.pageToDisplay)},scope.rotate=function(){"rotate0"===canvas.getAttribute("class")?canvas.setAttribute("class","rotate90"):"rotate90"===canvas.getAttribute("class")?canvas.setAttribute("class","rotate180"):"rotate180"===canvas.getAttribute("class")?canvas.setAttribute("class","rotate270"):canvas.setAttribute("class","rotate0")},scope.$watch("pageNum",function(newVal){scope.pageToDisplay=parseInt(newVal),null!==pdfDoc&&scope.renderPage(scope.pageToDisplay)}),scope.$watch("pdfUrl",function(newVal){""!==newVal&&(debug&&console.log("pdfUrl value change detected: ",scope.pdfUrl),url=newVal,scope.pageNum=scope.pageToDisplay=pageToDisplay,pdfLoaderTask?pdfLoaderTask.destroy().then(function(){renderPDF()}):renderPDF())})}}}])}(); \ No newline at end of file diff --git a/example/js/directives/angular-pdf.min.js b/example/js/directives/angular-pdf.min.js index 73d4123..ae6a771 100644 --- a/example/js/directives/angular-pdf.min.js +++ b/example/js/directives/angular-pdf.min.js @@ -1,2 +1,2 @@ -/*! Angular-PDF Version: 1.5.0 | Released under an MIT license */ +/*! Angular-PDF Version: 1.5.1 | Released under an MIT license */ !function(){"use strict";angular.module("pdf",[]).directive("ngPdf",["$window",function($window){var renderTask=null,pdfLoaderTask=null,debug=!1,backingScale=function(canvas){var ctx=canvas.getContext("2d"),dpr=window.devicePixelRatio||1,bsr=ctx.webkitBackingStorePixelRatio||ctx.mozBackingStorePixelRatio||ctx.msBackingStorePixelRatio||ctx.oBackingStorePixelRatio||ctx.backingStorePixelRatio||1;return dpr/bsr},setCanvasDimensions=function(canvas,w,h){var ratio=backingScale(canvas);return canvas.width=Math.floor(w*ratio),canvas.height=Math.floor(h*ratio),canvas.style.width=Math.floor(w)+"px",canvas.style.height=Math.floor(h)+"px",canvas.getContext("2d").setTransform(ratio,0,0,ratio,0,0),canvas};return{restrict:"E",templateUrl:function(element,attr){return attr.templateUrl?attr.templateUrl:"partials/viewer.html"},link:function(scope,element,attrs){function clearCanvas(){ctx&&ctx.clearRect(0,0,canvas.width,canvas.height)}function renderPDF(){clearCanvas();var params={url:url,withCredentials:creds};httpHeaders&&(params.httpHeaders=httpHeaders),url&&url.length&&(pdfLoaderTask=PDFJS.getDocument(params),pdfLoaderTask.onProgress=scope.onProgress,pdfLoaderTask.onPassword=scope.onPassword,pdfLoaderTask.then(function(_pdfDoc){"function"==typeof scope.onLoad&&scope.onLoad(),pdfDoc=_pdfDoc,scope.renderPage(scope.pageToDisplay),scope.$apply(function(){scope.pageCount=_pdfDoc.numPages})},function(error){error&&"function"==typeof scope.onError&&scope.onError(error)}))}element.css("display","block");var url=scope.pdfUrl,httpHeaders=scope.httpHeaders,pdfDoc=null,pageToDisplay=isFinite(attrs.page)?parseInt(attrs.page):1,pageFit="page-fit"===attrs.scale,scale=attrs.scale>0?attrs.scale:1,canvasid=attrs.canvasid||"pdf-canvas",canvas=document.getElementById(canvasid);debug=!!attrs.hasOwnProperty("debug")&&attrs.debug;var creds=attrs.usecredentials,ctx=canvas.getContext("2d"),windowEl=angular.element($window);windowEl.on("scroll",function(){scope.$apply(function(){scope.scroll=windowEl[0].scrollY})}),PDFJS.disableWorker=!0,scope.pageNum=pageToDisplay,scope.renderPage=function(num){renderTask&&renderTask._internalRenderTask.cancel(),pdfDoc.getPage(num).then(function(page){var viewport,pageWidthScale,renderContext;if(pageFit){viewport=page.getViewport(1);var clientRect=element[0].getBoundingClientRect();pageWidthScale=clientRect.width/viewport.width,scale=pageWidthScale}viewport=page.getViewport(scale),setCanvasDimensions(canvas,viewport.width,viewport.height),renderContext={canvasContext:ctx,viewport:viewport},renderTask=page.render(renderContext),renderTask.promise.then(function(){"function"==typeof scope.onPageRender&&scope.onPageRender()}).catch(function(reason){console.log(reason)})})},scope.goPrevious=function(){scope.pageToDisplay<=1||(scope.pageToDisplay=parseInt(scope.pageToDisplay)-1,scope.pageNum=scope.pageToDisplay)},scope.goNext=function(){scope.pageToDisplay>=pdfDoc.numPages||(scope.pageToDisplay=parseInt(scope.pageToDisplay)+1,scope.pageNum=scope.pageToDisplay)},scope.zoomIn=function(){return pageFit=!1,scale=parseFloat(scale)+.2,scope.renderPage(scope.pageToDisplay),scale},scope.zoomOut=function(){return pageFit=!1,scale=parseFloat(scale)-.2,scope.renderPage(scope.pageToDisplay),scale},scope.fit=function(){pageFit=!0,scope.renderPage(scope.pageToDisplay)},scope.changePage=function(){scope.renderPage(scope.pageToDisplay)},scope.rotate=function(){"rotate0"===canvas.getAttribute("class")?canvas.setAttribute("class","rotate90"):"rotate90"===canvas.getAttribute("class")?canvas.setAttribute("class","rotate180"):"rotate180"===canvas.getAttribute("class")?canvas.setAttribute("class","rotate270"):canvas.setAttribute("class","rotate0")},scope.$watch("pageNum",function(newVal){scope.pageToDisplay=parseInt(newVal),null!==pdfDoc&&scope.renderPage(scope.pageToDisplay)}),scope.$watch("pdfUrl",function(newVal){""!==newVal&&(debug&&console.log("pdfUrl value change detected: ",scope.pdfUrl),url=newVal,scope.pageNum=scope.pageToDisplay=pageToDisplay,pdfLoaderTask?pdfLoaderTask.destroy().then(function(){renderPDF()}):renderPDF())})}}}])}(); \ No newline at end of file diff --git a/package.json b/package.json index 9364557..0d8c79a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-pdf", - "version": "1.5.0", + "version": "1.5.1", "main": "dist/angular-pdf.js", "author": "Sayanee ", "description": "An Angularjs directive to display PDF in the browser with PDFJS.", diff --git a/readme.md b/readme.md index 6a12867..613ee09 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # angular-pdf [![Build Status](https://travis-ci.org/sayanee/angularjs-pdf.svg)](https://travis-ci.org/sayanee/angularjs-pdf) [![Dependency Status](https://gemnasium.com/sayanee/angularjs-pdf.svg)](https://gemnasium.com/sayanee/angularjs-pdf) -Version: 1.5.0 +Version: 1.5.1 >An [AngularJS](http://angularjs.org/) [directive](http://docs.angularjs.org/guide/directive) `ng-pdf` to display PDF files with [PDFJS](http://mozilla.github.io/pdf.js/). diff --git a/src/angular-pdf.js b/src/angular-pdf.js index ecdb98f..bb8cabc 100644 --- a/src/angular-pdf.js +++ b/src/angular-pdf.js @@ -1,4 +1,4 @@ -/*! Angular-PDF Version: 1.5.0 | Released under an MIT license */ +/*! Angular-PDF Version: 1.5.1 | Released under an MIT license */ (function() { 'use strict';