Skip to content

Commit 2bb9571

Browse files
committed
Release v1.0.0
1 parent 1fbea7a commit 2bb9571

File tree

6 files changed

+39
-26
lines changed

6 files changed

+39
-26
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-pdf",
3-
"version": "0.4.0",
3+
"version": "1.0.0",
44
"description": "An Angularjs directive <ng-pdf> to display PDF in the browser with PDFJS.",
55
"main": "./dist/angular-pdf.js",
66
"license": "MIT",

dist/angular-pdf.js

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Angular-PDF Version: 0.4.0 | (C) Sayanee Basu 2014, released under an MIT license */
1+
/*! Angular-PDF Version: 1.0.0 | (C) Sayanee Basu 2014, released under an MIT license */
22
(function() {
33

44
'use strict';
@@ -102,26 +102,30 @@
102102
}
103103
};
104104

105-
PDFJS.getDocument(url, null, null, scope.onProgress).then(
106-
function(_pdfDoc) {
107-
if (typeof scope.onLoad === 'function' ) {
108-
scope.onLoad();
109-
}
110-
111-
pdfDoc = _pdfDoc;
112-
scope.renderPage(scope.pageToDisplay);
113-
114-
scope.$apply(function() {
115-
scope.pageCount = _pdfDoc.numPages;
116-
});
117-
}, function(error) {
118-
if (error) {
119-
if (typeof scope.onError === 'function') {
120-
scope.onError(error);
121-
}
122-
}
105+
function renderPDF() {
106+
if (url && url.length) {
107+
PDFJS.getDocument(url, null, null, scope.onProgress).then(
108+
function(_pdfDoc) {
109+
if (typeof scope.onLoad === 'function') {
110+
scope.onLoad();
111+
}
112+
113+
pdfDoc = _pdfDoc;
114+
scope.renderPage(scope.pageToDisplay);
115+
116+
scope.$apply(function() {
117+
scope.pageCount = _pdfDoc.numPages;
118+
});
119+
}, function(error) {
120+
if (error) {
121+
if (typeof scope.onError === 'function') {
122+
scope.onError(error);
123+
}
124+
}
125+
}
126+
);
123127
}
124-
);
128+
}
125129

126130
scope.$watch('pageNum', function(newVal) {
127131
scope.pageToDisplay = parseInt(newVal);
@@ -130,6 +134,15 @@
130134
}
131135
});
132136

137+
scope.$watch('pdfUrl', function(newVal) {
138+
if (newVal !== '') {
139+
console.log('pdfUrl value change detected: ', scope.pdfUrl);
140+
url = newVal;
141+
scope.pageToDisplay = 1;
142+
renderPDF();
143+
}
144+
});
145+
133146
}
134147
};
135148
} ]);

dist/angular-pdf.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/js/directives/angular-pdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Angular-PDF Version: 0.4.0 | (C) Sayanee Basu 2014, released under an MIT license */
1+
/*! Angular-PDF Version: 1.0.0 | (C) Sayanee Basu 2014, released under an MIT license */
22
(function() {
33

44
'use strict';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-pdf",
3-
"version": "0.4.0",
3+
"version": "1.0.0",
44
"author": "Sayanee <[email protected]>",
55
"description": "An Angularjs directive <ng-pdf> to display PDF in the browser with PDFJS.",
66
"repository": {

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# angular-pdf [![Build Status](https://travis-ci.org/sayanee/angularjs-pdf.png)](https://travis-ci.org/sayanee/angularjs-pdf) [![Dependency Status](https://gemnasium.com/sayanee/angularjs-pdf.png)](https://gemnasium.com/sayanee/angularjs-pdf)
22

3-
Version: 0.4.0
3+
Version: 1.0.0
44

55
>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/).
66

0 commit comments

Comments
 (0)