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.

Promise problem rendering page

See original GitHub issue

Hello.

I am using PDF.js in an angular service to make a custom viewer, the problem is the render page promise, the render task is working and rendering the PDF page in the canvas but i need a callback and for some reasons the promise is not working.

PDF version: 1.0.68

var renderContext = {
    canvasContext: context,
    viewport: viewport,
};

var renderTask = page.render(renderContext);

renderTask.then(function(){
    console.log("SUCCESS");
}, function(error){
    console.error("ERROR");
});

I also have tried:

renderTask.promise.then(function(){
    console.log("SUCCESS");
}, function(error){
    console.error("ERROR");
});

And

var renderTask = page.render(renderContext).then(function(){
    alert("PROMISE");
});

The page renders well but the problem is the promise, debugging in the chrome console i found that renderTask.promise:

Promise {resolve: function, reject: function, then: function, catch: function}

I just do not understand, how is supposed to be used the promise in page.render().

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
yurydelendikcommented, May 27, 2014

i have downgrade to v1.0.233 and the promise are working again

1.0.68 is older than 1.0.233, sounds like you upgraded

PDF.js needs an official bower package

We are not experts in bower. There were few bower users who are interested in helping, but no actions were taken so far – just talking.

0reactions
Kesymarucommented, May 27, 2014

Well i have downgrade to v1.0.233 and the promise are working again, i do not know if bower cause the problem updating the source, but i think that PDF.js needs an official bower package including a build and the source code.

Thanks for your time, problem solved!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does the Promise object block rendering? - Stack Overflow
Promises are a way to manage asynchronous code, not a way to make code asynchronous, nor a way to simulate multithreading.
Read more >
Examples
The example demonstrates how promises can be used to handle errors during loading. It also demonstrates how to wait until a page is...
Read more >
OfflineAudioContext.startRendering() - Web APIs | MDN
startRendering . When the startRendering() promise resolves, rendering has completed and the output AudioBuffer is returned out of the promise.
Read more >
Suspense on React: The Act of Rendering While You Load
The above codebase has a loading state or a default UI rendered by the app while it waits for the promise to be...
Read more >
UI5 Rendering Issues using promises - SAP Community
From a quick review, I think you need to use a model to capture the response from the promise, instead of just variables....
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