How to know if PDF.JS has finished rendering?

后端 未结 12 1130
情深已故
情深已故 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:58

    I was also struggling with this problem.. the solution that i used is:

    //Step 1: store a refer to the renderer
    var pageRendering = page.render(renderContext);
    //Step : hook into the pdf render complete event
    var completeCallback = pageRendering.internalRenderTask.callback;
    pageRendering.internalRenderTask.callback = function (error) {
      //Step 2: what you want to do before calling the complete method                  
      completeCallback.call(this, error);
      //Step 3: do some more stuff
    };
    

提交回复
热议问题