How to know if PDF.JS has finished rendering?

后端 未结 12 1136
情深已故
情深已故 2020-12-13 14:44

I am using PDF.JS to render pdf pages into different canvas elements. my requirement is to capture the output of the canvas and to display it as an image. Is there some even

12条回答
  •  一向
    一向 (楼主)
    2020-12-13 14:57

    Lyon's solution of more robust. But this is the simplest solution I could find.

    var renderTask = pdfPage.render(renderContext);
    renderTask.promise.then(
      function pdfPageRenderCallback() {
        pageViewDrawCallback(null);
      },
      function pdfPageRenderError(error) {
        pageViewDrawCallback(error);
      }
    );
    
    • Scrapped and modified from the code found at: http://mozilla.github.io/pdf.js/web/viewer.html

提交回复
热议问题