I'm making a Firefox add-on extension to insert
a pdf document in the translated page of Google and I want to use pdf.js
. Don't want to use embed or iframe tags to do it, I want to do my own pdf viewer.
I'm trying to use the pdj.js
library in a Firefox add-on, but it not work.
I have already tried to do it adding this in manifest.json
.
"content_scripts": [
{
"matches":["*://translate.google.com/*"],
"js": ["script.js","pdf.js"]
}
[enter image description here][1] ]
but when I do:
pdfjsLib.getDocument(pdf_url);
it not working, the script stop working.
I do try to add the script in the head of the page doing
var pdf_js = document.createElement('script');
pdf_js.src = 'https://mozilla.github.io/pdf.js/build/pdf.js';
document.getElementsByTagName('head')[0].appendChild(pdf_js);
and it does not work either. But when I use pdfjsLib from debug console in Firefox it works, but from the script that I use for the addon, pdfjsLib.getDocument
function it not working.
I had a similar problem when I used jQuery, the library does not work in the script.
I tried watching the navigation console as suggested by Jaromanda X and I got this
ReferenceError:
pdfjsLib is not defined