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.

Roman Podolski
  • 329
  • 3
  • 17
  • possible duplicate of [Phantomjs page.content isn't retrieving the page content](http://stackoverflow.com/questions/26382041/phantomjs-page-content-isnt-retrieving-the-page-content) – Artjom B. Aug 03 '15 at 08:50

1 Answers1

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.

nioKi
  • 1,259
  • 9
  • 17