0

I am writing an angular-app, that uses Mozilla's library PDFJS. Unfortunately, when executing the unit-tests of the application, it seems that PhantomJS can't find parts of the PDFJS-lib.

Here is the error message:

PhantomJS 1.9.8 (Linux 0.0.0) ERROR
TypeError: 'undefined' is not a function (near '...}.bind(this), REJECTION_TI...')
at /home/[...]/bower_components/pdfjs-dist/build/pdf.js:1222

I need to use PhantomJS because of my CI infrastructure.

1

1 Answer 1

0

Your problem seems to come from the 'bind' function.

If I remember correctly, PhantomJS < 2.0 doesn't support bind natively, hence the 'undefined is not a function' message. You can use a polyfill to overcome this problem, see:

Issue on GitHub: https://github.com/ariya/phantomjs/issues/10522

Polyfill on NPM : https://www.npmjs.com/package/phantomjs-polyfill

If you don't want to use NPM, there is a polyfill also available from the MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill

It also seems that PhantomJS 2.* now handles it correctly, but I haven't tried.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.