sayanee / angularjs-pdf

:page_facing_up: An AngularJS directive <ng-pdf> to display PDF files with PDFJS
http://sayan.ee/angularjs-pdf/
MIT License
494 stars 248 forks source link

ReferenceError: PDFJS is not defined #192

Closed mdali602 closed 7 years ago

mdali602 commented 7 years ago

I'm getting error: ReferenceError: PDFJS is not defined.

The complete error is as follows:-

ionic.bundle.js:26771 ReferenceError: PDFJS is not defined at link (http://localhost:8100/js/angular-pdf/angular-pdf.js:7:2319) at invokeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:22970:9) at nodeLinkFn (http://localhost:8100/lib/ionic/js/ionic.bundle.js:22369:11) at http://localhost:8100/lib/ionic/js/ionic.bundle.js:22709:13 at processQueue (http://localhost:8100/lib/ionic/js/ionic.bundle.js:29104:28) at http://localhost:8100/lib/ionic/js/ionic.bundle.js:29120:27 at Scope.$eval (http://localhost:8100/lib/ionic/js/ionic.bundle.js:30372:28) at Scope.$digest (http://localhost:8100/lib/ionic/js/ionic.bundle.js:30188:31) at Scope.$apply (http://localhost:8100/lib/ionic/js/ionic.bundle.js:30480:24) at done (http://localhost:8100/lib/ionic/js/ionic.bundle.js:24801:47)

Please suggest me why this is happening...

dennybiasiolli commented 7 years ago

Hi @mdali602 , Have you included PDFJS in your sources?

dennybiasiolli commented 7 years ago

@mdali602 did you resolved your issue?

sblantipodi commented 7 years ago

I have the same problem. I am including sources like this: require.config({ paths : { moment : '/addons/osst/bower_components/moment/moment', text: '../../../../bower_components/requirejs-plugins/lib/text', json: '../../../../bower_components/requirejs-plugins/src/json', pdfjs : '/addons/osst/bower_components/pdfjs-dist/build/pdf', pdf : '/addons/osst/bowercomponents/angular-pdf/dist/angular-pdf.min' } }); define([ 'angular', 'lodash', 'json!addons/osst/widgets/osst-summary/base-config.json', 'moment', 'pdfjs', 'pdf'
], function(angular,
, widgetConfig, moment, pdf) { 'use strict'; var control = angular.module('control', ['commonsEvents', 'dataExchangeServices', 'pdf']);

control.controller('control', ['$scope', '$rootScope', '$log', 'events', '$compile', '$filter', 
    function($scope, $rootScope, $log, events, $compile, $filter) {

    ...........

any help please?

dennybiasiolli commented 7 years ago

@sblantipodi can you please provide a full example of your code on jsfiddle?

sblantipodi commented 7 years ago

this library seems broken while using requirejs. define('pdfjs-dist/build/pdf', ['exports'], factory); why use exports?

sblantipodi commented 7 years ago

and why not use the newer pdfjs? https://github.com/mozilla/pdfjs-dist/blob/master/build/pdf.js#L12184

dennybiasiolli commented 7 years ago

why use exports?

This is in pdfjs code, not in our directive.

and why not use the newer pdfjs?

Because latest pdf.js stable version is v1.7.225