Pdf.js: Can't get pdf.js working with edge

Created on 17 Apr 2020  路  3Comments  路  Source: mozilla/pdf.js

Configuration:

  • Web browser and its version: Edge 44.18362.449.0
  • Operating system and its version: Windows 10
  • PDF.js version: 2.5.95

Steps to reproduce the problem:

  1. git clone ...
  2. npm install
  3. gulp generic
  4. Place the generic folder in an apache server
  5. Access to the URL

Hello, I'm trying to setup a pdf viewer on my web site. All is working fine with firefox/google chrome. But Microsoft edge tells me:

PDF.js v2.5.95 (identifiant de compilation : c218e94f)
Message : The browser/environment lacks native support for critical functionality used by the PDF.js library (e.g. ReadableStream and/or Promise.allSettled); please use an ES5-compatible build instead.

If I test with gulp server directly, all browser are working. Any idea please ?

Most helpful comment

Thanks !!! I'll try asap

[EDIT] It's working with all browsers. Thanks. I did not find any documentation about generic-es5

All 3 comments

gulp generic

But Microsoft edge tells me:

PDF.js v2.5.95 (identifiant de compilation : c218e94)
Message : The browser/environment lacks native support for critical functionality used by the PDF.js library (e.g. ReadableStream and/or Promise.allSettled); please use an ES5-compatible build instead.

The error message is explicitly telling you to use an ES5-compatible build, which based on the quoted gulp command above you don't seem to do; hence you should use gulp generic-es5 instead.


Generally speaking, it's also strongly advised to use official releases in production (rather than the master branch directly); see https://github.com/mozilla/pdf.js/releases

Thanks !!! I'll try asap

[EDIT] It's working with all browsers. Thanks. I did not find any documentation about generic-es5

var pdfjsLib = require("pdfjs-dist/es5/build/pdf.js");
var url = 'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf';
var loadingTask = pdfjsLib.getDocument(url);

loadingTask.promise.then(function (pdf) {
    console.log(pdf);
}).catch(function (error){
    console.log(error)
})

That answer saved me like 5h of searching:
Source: https://stackoverflow.com/a/64189798/7027380

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timvandermeij picture timvandermeij  路  4Comments

patelsumit5192 picture patelsumit5192  路  3Comments

SehyunPark picture SehyunPark  路  3Comments

AlexP3 picture AlexP3  路  3Comments

jigskpatel picture jigskpatel  路  3Comments