Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setupFakeWorker not a function

45 views
Skip to first unread message

OneMHz

unread,
Apr 9, 2012, 12:56:15 PM4/9/12
to mozilla-d...@lists.mozilla.org
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);

Julian Viereck

unread,
Apr 11, 2012, 1:37:31 AM4/11/12
to mozilla.d...@googlegroups.com, mozilla-d...@lists.mozilla.org
Hi,

can you please share your complete HTML file including the JS, such that I can play with it? I'm more then happy to look into this, and having the files you have would make it much more easier for me.

Julian

Julian Viereck

unread,
Apr 11, 2012, 1:37:31 AM4/11/12
to mozilla-d...@lists.mozilla.org, mozilla-d...@lists.mozilla.org
Hi,

can you please share your complete HTML file including the JS, such that I can play with it? I'm more then happy to look into this, and having the files you have would make it much more easier for me.

Julian

On Monday, April 9, 2012 9:56:15 AM UTC-7, OneMHz wrote:
0 new messages