Hi,
I am trying to integrate PDF.JS Express in salessforce lightning web component. I am facing the issue below. However I can the PDF is getting rendered, but the instance promise is not getting resolved.
Detailed description of issue
In browser console log , it throws error
“Viewer isn’t instantiated correctly. It could be caused by the ‘path’ option in the WebViewer constructor not being defined correctly. The ‘path’ option should be relative to the HTML file you’re loading the script on and the lib folder needs to be publicly accessible”
shows warning - “Viewer is on a different domain, the promise from WebViewer function is rejected and API functions will not work because of cross domain permissions.”
Expected behaviour
No errors should be thrown at the time of intialization, so that the instance gets available in promise. and use annotations later on.
Link to document
{Provide a link to the document in question if possible}
Code snippet
const viewElement = this.template.querySelector(".viewer");
const viewer = WebViewer(
{
path: myObj.libUrl,
config: myfilesUrl + "/config.js",
initialDoc: url,
fullAPI: myObj.fullAPI,
enableAnnotations: true,
enableMeasurement: true,
disabledElements: ["signatureToolButton"]
},
viewElement
).then((instance) => {
const { docViewer, annotManager } = instance;
docViewer.on("documentLoaded", () => {
docViewer
.getDocument()
.removePages([1])
.then((res) => {
console.log(res);
});
});
});