How to use pdf.js library in a firefox addon

230
May 04, 2019, at 1:10 PM

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

Rent Charter Buses Company
READ ALSO
How to integrate pdf viewer in website and customize it [on hold]

How to integrate pdf viewer in website and customize it [on hold]

Hello friends I'm working on website projects which needs to integrate PDF viewer and I also wanted to customize such that users can't use right click and download button will disabledand also suggest me if we want to see eBook which format will be suitable

157
loop returning the same value (Angular)

loop returning the same value (Angular)

I need to replace a template array with values from another array and push it to the final resultThis is what I have tried, the problem is that I get the same value when I loop

142
What is the best way to add snapshot on a collection of firestore when documents are in millions?

What is the best way to add snapshot on a collection of firestore when documents are in millions?

I have a collection like Post (Facebook)I'm fetching the documents 100-100 on scroll down (pagination) in descending order (on basis of the value of creation)

170
changin inputMask with annotation in Vaadin

changin inputMask with annotation in Vaadin

I have an annotation @Mask that holds only String value, and I want to mask my fields with this annotation

135