Product: Web Viewer
Product Version: 7.3.3
Please give a brief summary of your issue:
Followed steps provided in the Running Full APIs without viewer sample, but I’m receiving multiple error message and not receiving an alert.
Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
I simply followed your steps and received the following errors:
CoreControls.js:544 [Deprecation] SharedArrayBuffer will require cross-origin isolation as of M92, around July 2021. See SharedArrayBuffer updates in Android Chrome 88 and Desktop Chrome 92 - Chrome Developers for more details.
f @ CoreControls.js:544
iframe.html:1 Access to script at ‘file:someServer/c$/users/user/Desktop/ViewerPOC/WebViewer/lib/core/pdf/WasmThread.js’ from origin ‘null’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
WebViewer/lib/core/pdf/WasmThread.js:1 Failed to load resource: net::ERR_FAILED
CoreControls.js:499 Uncaught DOMException: Blocked a frame with origin “null” from accessing a cross-origin frame.
at HTMLIFrameElement.r.onload (file://someServer/c$/users/user/Desktop/ViewerPOC/WebViewer/lib/core/CoreControls.js:499:494)
CoreControls.js:499 Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘null’) does not match the recipient window’s origin (‘null’).
Please provide a link to a minimal sample where the issue is reproducible:
SampleTest.html
<head>
<script src="WebViewer/lib/core/CoreControls.js"></script>
<script src="WebViewer/samples/FileSaver.min.js"></script>
<script src="WebViewer/lib/core/pdf/PDFNet.js"></script>
<script src="WebViewer/samples/full-apis/Setup.js"></script>
</head>
<body>
<script src="SampleTest.js"></script>
</body>
SampleTest.js
(async function() {
"use strict";
const licenseKey = 'Insert commercial license key here after purchase';
// the path to where the PDF worker files are
CoreControls.setWorkerPath('WebViewer/lib/core');
async function main() {
try {
// creates an empty pdf document
const doc = await PDFNet.PDFDoc.createFromURL("Sample.pdf");
doc.initSecurityHandler();
// Locks all operations on the document
doc.lock();
// insert user code after this point
const pgnum = await doc.getPageCount();
alert(`Test Complete! Your file has ${pgnum} pages`);
} catch(err) {
console.log(err.stack)
}
}
await PDFNet.runWithCleanup(main, licenseKey);
// Alt: PDFNet.runWithoutCleanup(main, licenseKey);
// 'runWithoutCleanup' does not deallocate anything after finishing.
})();