I would like to use this to show PDF in my SPA.
I tried to build a single example but it didn't work. Look this Plunker
http://plnkr.co/edit/nZAjYr?p=preview
In this example my pdf is in http://example.com/file.pdf
I really don't know where is the error, maybe it be in my controler:
angular.module('app', ['pdfjsViewer']);
angular.module('app').controller('AppCtrl', function ($scope, $http, $timeout) {
var url = 'http://example.com/file.pdf';
$scope.pdf = {
src: url, // get pdf source from a URL that points to a pdf
data: null // get pdf source from raw data of a pdf
};
getPdfAsArrayBuffer(url).then(function (response) {
$scope.pdf.data = new Uint8Array(response.data);
}, function (err) {
console.log('failed to get pdf as binary:', err);
});
function getPdfAsArrayBuffer (url) {
return $http.get(url, {
responseType: 'arraybuffer',
headers: {
'foo': 'bar'
}
});
}
});
Can anyone helpe me please?