I'm guessing this is my fault, so sorry if this ends up being a
question, and not an issue. I'm trying to load a PDF from a string
(constraint of a third party web service I'm trying to integrate
with). I think I'm getting close, but I'm getting an odd error. I
downloaded the pre-built library from
https://raw.github.com/mozilla/pdf.js/gh-pages/build/pdf.js.
The line
this.setupFakeWorker();
is throwing an error "this.setupMessageHandler is not a function". I
see that it's defined in PDFDoc.prototype, but it doesn't seem like
that is being executed. I'm not sure if I'm doing anything wrong. I
based my code off your hello world example. Please let me know if I'm
doing something wrong.
PDFJS.disableWorker = true;
// Converting my string to an ArrayBuffer
var idx;
var len = stringData.length;
var arr = new Array(len);
for (idx = 0; idx < len; ++idx) {
arr[idx] = stringData.charCodeAt(idx) & 0xFF;
}
var pdfArrayBuffer = new Uint8Array(arr).buffer;
var data = StringToArrayBuffer(pdfArrayBuffer);
var pdf = new PDFJS.PDFDoc(data); // This is where the error comes
from
var page = pdf.getPage(1);
var scale = 1.5;
var canvas = document.getElementById('the-canvas');
var context = canvas.getContext('2d');
canvas.height = page.height * scale;
canvas.width = page.width * scale;
page.startRendering(context);