0x80070005 - JavaScript runtime error: Access is denied when using PDFJS with MS Word Add-in project

0

Recently, we've tried to add a library PDFJS to our Microsoft Office Add-in. There are files included pdf.js and pdf.worker.js into Scripts/PDFjs folder.

// Home.html
...
<script src="Scripts/PDFjs/pdf.js" type="text/javascript"></script>
...

// Home.js
Office.initialize = function (reason) {
    $(document).ready(function () {
         pdfjsLib.workerSrc = './pdf.worker.js';
    });
}

Visual Studio shows an exception and hangs:

SCRIPT5: Exception was thrown at line 2058, column 5 in https://localhost:44332/Scripts/PDFjs/pdf.js 0x80070005 - JavaScript runtime error: Access is denied. pdf.js (2058,5)

img_1

Also, worth to mention, when including pdf.worker.js from CDN(not locally), like src="https://npmcdn.com/pdfjs-dist@2.0.943/build/pdf.worker.js" then it works like a charm.

What could this be and how to make it work?
Thank you very much

microsoft-word
pdf
javascript
asked on Super User Feb 19, 2019 by V.7 • edited Feb 19, 2019 by V.7

1 Answer

0

A Visual Studio showed this exception even it is in try/catch block because it's loaded from local machine because it hangs on any local stored file's exception by default, but not remote. So, unchecking a checkbox "Break when this exception type if thrown" solved an issue.

Roel van:
The reason you didn't get it with CDN is because VS only breaks on exceptions in your own code. It now is considering the lib "your own code" because it's local.

Prove

answered on Super User Feb 20, 2019 by V.7

User contributions licensed under CC BY-SA 3.0