This is a complex situation wich I can´t find the anwser.
I am trying to implement PDF.js in my Asp Net MVC 4 project.
I have a view page responsable for displaying the pdf in the browser.
It works fine as long as I declare the api.js within this page.
I need to move the api.js call to the head in my layout view.
Doing this the api.js is loaded and I can see it in firebug.
Although the pdf is not loaded.
This is the api.js
http://pastebin.com/JAnZVcbC
The only part of the api.js I have changed is this:
if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') {
var workerSrc = '/pdf.js/worker_loader.js';
if (typeof workerSrc === 'undefined') {
error('No PDFJS.workerSrc specified');
}
try {
// Some versions of FF can't create a worker on localhost, see:
// https://bugzilla.mozilla.org/show_bug.cgi?id=683280
var worker = new Worker('/pdf.js/worker_loader.js');
var messageHandler = new MessageHandler('main', worker);
this.messageHandler = messageHandler;
As you can see I defined workerSrc with the URI pointing to the file.
Have you guys experience with this librarie and could give to me some advice on how to solve this problem?
Too complicated for me but I think you have to call PDFJS.getDocument after the page loads. You included javascript…OK… but do you trigger it?