From f54585fda55261bca26fc02cee639a4fc39645ad Mon Sep 17 00:00:00 2001 From: Denny Biasiolli Date: Sun, 4 Dec 2016 21:21:01 +0100 Subject: [PATCH] Release v1.4.0 --- 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 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 9fae8be..1cb2f1b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-pdf", - "version": "1.3.0", + "version": "1.4.0", "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 06c9009..d258022 100644 --- a/dist/angular-pdf.js +++ b/dist/angular-pdf.js @@ -1,4 +1,4 @@ -/*! Angular-PDF Version: 1.3.1 | Released under an MIT license */ +/*! Angular-PDF Version: 1.4.0 | Released under an MIT license */ (function() { 'use strict'; diff --git a/dist/angular-pdf.min.js b/dist/angular-pdf.min.js index 52cd772..ec7f1b8 100644 --- a/dist/angular-pdf.min.js +++ b/dist/angular-pdf.min.js @@ -1,2 +1,2 @@ -/*! Angular-PDF Version: 1.3.1 | Released under an MIT license */ +/*! Angular-PDF Version: 1.4.0 | 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,null,null,scope.onProgress),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 52cd772..ec7f1b8 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.3.1 | Released under an MIT license */ +/*! Angular-PDF Version: 1.4.0 | 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,null,null,scope.onProgress),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 500e6cc..7b0d03f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-pdf", - "version": "1.3.1", + "version": "1.4.0", "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 93a648d..c2d6082 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.3.1 +Version: 1.4.0 >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/).