Pdf.js and viewer.js. Pass a stream or blob to the viewer

I’m using PDFJS.version = ‘1.0.1040’; PDFJS.build = ‘997096f’; The code that worked for me to get base64 pdf data loaded was this: function (base64Data) { var pdfData = base64ToUint8Array(base64Data); PDFJS.getDocument(pdfData).then(function (pdf) { pdf.getPage(1).then(function (page) { var scale = 1; var viewport = page.getViewport(scale); var canvas = document.getElementById(‘myCanvas’); var context = canvas.getContext(‘2d’); canvas.height = viewport.height; canvas.width … Read more

How to render PDF using pdf.js viewer in PyQt?

Below are some more up-to-date demo scripts for using pdf.js with PyQt4/QtWebKit or PyQt5/QtWebEngine. To try these, first download the latest stable version of pdf.js and unpack the zip file into a suitable location. (NB: if you’re on Linux your distro may already have a pdf.js package, so that could be installed instead). UPDATE: As … 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