How to know if PDF.JS has finished rendering?

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 … Read more

PDF.js scale PDF on fixed width

I updated the example from the Pdf.js github http://jsbin.com/pdfjs-prevnext-v2/edit#html,live to scale properly to a fixed canvas width. See http://jsfiddle.net/RREv9/ for my code. The important line is var viewport = page.getViewport(canvas.width / page.getViewport(1.0).width); because the expression canvas.width / page.getViewport(1.0).width gives us the appropriate scaling factor. You should change the width of your canvas not with css … Read more

Pdf.js: rendering a pdf file using a base64 file source instead of url

from the sourcecode at http://mozilla.github.com/pdf.js/build/pdf.js /** * This is the main entry point for loading a PDF and interacting with it. * NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR) * is used, which means it must follow the same origin rules that any XHR does * e.g. No … Read more

How to Use pdf.js [closed]

There is documentation available on their github readme. They cite the following example code: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ // // See README for overview // ‘use strict’; // // Fetch the PDF document from the URL using promises … Read more

tech