question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PDFJS.getDocument not working

See original GitHub issue

I’m running a grails app on local host (which i know there’s an issue with pdf.js and local file system) and instead of using a file: url which i know would fail i’m passing in a typed javascript array and it’s still failing. To be correct it’s not telling me anything but “Warning: Setting up fake worker.” and then it does nothing.

this.base64ToBinary = function(dataURI) {
        var BASE64_MARKER = ';base64,';
        var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
        var base64 = dataURI.substring(base64Index);
        var raw = window.atob(base64);
        var rawLength = raw.length;
        var array = new Uint8Array(new ArrayBuffer(rawLength));

        for(i = 0; i < rawLength; i++) {
        array[i] = raw.charCodeAt(i);
        }
        return array;
    };

PDFJS.disableWorker = true; // due to CORS

// I convert some base64 data to binary data here which comes back correctly
var data = utilities.base64ToBinary(result);

PDFJS.getDocument(data).then(function (pdf) {
         //nothing console logs or reaches here
         console.log(pdf);
}).catch(function(error){
//no error message is logged either
            console.log("Error occurred", error);
        });

I’m wondering if I just don’t have it set up correctly? Can I use this library purely on the client side by just including pdf.js or do I need to include viewer.js too? and also i noticed compatibility file… the set up isn’t very clear and this example http://jsfiddle.net/epistemex/LUNaJ/ works and mine doesn’t and I’m not understanding the difference. Also if I use the url supplied in that example it also says the same thing.

screen shot 2014-12-31 at 11 59 17 am

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

25reactions
yurydelendikcommented, Dec 31, 2014

Closing as invalid.

3reactions
btm1commented, Jan 2, 2015

“That will not help in case when pdf.js name is changed or part of the combined file.” true but aside from my own issues using grails you should just loop through them anyways to make the standard method more accurate. It’s full of holes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PDFJS.getDocument not working and not throwing an error
To solve this, I had to add. PDFJS.disableWorker = true;. to the beginning of my loadPage function. From View PDF files directly within ......
Read more >
PDFJS.getDocument('...') not working · Issue #1913 - GitHub
When I try to run the live demo (http://mozilla.github.com/pdf.js/web/viewer.html) offline, the pdf.js fails to load a PDF.
Read more >
How to use the pdfjs-dist.getDocument function in pdfjs-dist
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
Solved: PDF Preview Issues with pdf.js 1.10.100. How to up...
Solved: Hello, I have an Alfresco 5.0 CE application (we use share-frontend) and upgraded to version pdf.js 1.10.100 (with the help of this...
Read more >
pdfjs-dist.getDocument JavaScript and Node.js code examples
getDocument (Showing top 1 results out of 315). Tabnine vs. GitHub Copilot. Why developers prefer Tabnine over GitHub Copilot?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found