Skip to content

Commit 056cf17

Browse files
committed
Add posibility to add credentials for situations when pdf url need authentication
Use like this: <ng-pdf template-url="/tpl/pdfTemplate.html" usecredentials="1"></ng-pdf>
1 parent 055afd3 commit 056cf17

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dist/angular-pdf.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
var pageNum = (attrs.page ? attrs.page : 1);
3737
var scale = attrs.scale > 0 ? attrs.scale : 1;
3838
var canvas = (attrs.canvasid ? document.getElementById(attrs.canvasid) : document.getElementById('pdf-canvas'));
39+
var creds = attrs.usecredentials;
3940
var ctx = canvas.getContext('2d');
4041
var windowEl = angular.element($window);
4142

@@ -124,7 +125,10 @@
124125

125126
function renderPDF() {
126127
if (url && url.length) {
127-
PDFJS.getDocument(url, null, null, scope.onProgress).then(
128+
PDFJS.getDocument({
129+
'url': url,
130+
'withCredentials': creds
131+
}, null, null, scope.onProgress).then(
128132
function(_pdfDoc) {
129133
if (typeof scope.onLoad === 'function') {
130134
scope.onLoad();

0 commit comments

Comments
 (0)