Sunday, 4 June 2017

Aurelia-TypeScript include PDFJS

I am currently trying to import PDFJS into my Aurelia Application.

After installing PDFJS using npm install --save pdfjs-dist I am able to include PDFJS like the following: import { PDFJS } from 'pdfjs-dist';

My problem now is, that when I do not call any Method in PDFJS everything works fine. (Obviously, but tested if the IMPORT works)

But when I add the following code to my function which should display the pdf:

PDFJS.disableWorker = true;
// Using DocumentInitParameters object to load binary data.
var loadingTask = PDFJS.getDocument({ data: base64data });

the browser (Chrome) sends me the following error (in aurelia-logging-console.js:47):

ERROR [app-router] TypeError: Cannot set property hasCanvasTypedArrays of #<Object> which has only a getter
    at Object._typeof2 (pdf.js:5607)
    at __w_pdfjs_require__ (pdf.js:45)
    at Object._typeof (pdf.js:11058)
    at __w_pdfjs_require__ (pdf.js:45)
    at Object.defineProperty.value (pdf.js:91)
    at pdf.js:94
    at webpackUniversalModuleDefinition (pdf.js:18)
    at Object.<anonymous> (pdf.js:25)
    at Object.49 (app.js?v=c8tKAchbOda5lUkRKXQreBvEOaUb79gJ1vCVkEJVFSw:31970)
    at __webpack_require__ (bootstrap 9935a8e…:686)

Any suggestions what might be the problem? Is the Import wrong? Do I need to include *.js files for using PDFJS?

The Error occurs as soon as I call any Method or Attribute in PDFJS.



via Thomas Stockinger

No comments:

Post a Comment