'pdfjsLib not initializing and is undefined
included files are
<script src="~/Scripts/pdf.js"></script>
<script src="~/Scripts/pdf.worker.js"></script>
<script src="~/Scripts/viewer.js"></script>
and i am trying to load pdf using below code
var url = 'http://gahp.net/wp-content/uploads/2017/09/sample.pdf';
var pdfjsLib = window['/Scripts/pdf'];
but pdfjsLib not initializing and is undefined
example is here example
and please also explane how we are create shortcut using window['something'] object
thanks
Solution 1:[1]
I don't know the context in which you're using this module, but, for me, I started experiencing the "pdfjsLib is not defined" issue when I upgraded from Drupal 8 to Drupal 9. It turns out that all I needed was to upgrade the pdf.js library to its latest version. If you are using that library in your solution, visit https://mozilla.github.io/pdf.js/getting_started/#download and upgrade your version to the latest stable version. I can't guarantee it'll solve your issue, but it's a simple first step (and it solved my issue).
Solution 2:[2]
pdfjsLib not initialized when you folder path is changed You have to change path if not default from viewer.js and pdf.worker.js and other libraries
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tom Bisciglia |
| Solution 2 | zubair Ahmad |
