Are you seeing any errors in the console? Is the request to auth.pdfjs.express successful (returning 200)? Are there any other suspicious 404s in the network tab?
Also it would be very useful if I could get access to that URL somehow.
I would be glad to have a zoom conference with you and demonstrate the issue… and you can walk through the code even to see what we are doing. We would like to get this resolved if possible tomorrow 7/13/2021. Thanks.
The errors you are seeing are due to WebViewer not being able to load its assets properly. As the error states, all the resources must be available where-ever you specify in the path parameter.
Note that these resources cannot be loaded from a different domain due to browser restrictions (as the first warning message states).
I actually have a salesforce specialist on my team, I will chat with them and see the best way to load these assets in Salesforce.
I was told that you need to load assets a bit differently in salesforce (assuming you are storing assets in staticresources):
First you need to import:
import { loadScript } from 'lightning/platformResourceLoader';
And then initialize the project like so:
export default class PdftronWvInstance extends LightningElement {
//... shortened
renderedCallback() {
var self = this;
//use flag to prevent re-initialization
if (this.uiInitialized) {
return;
}
this.uiInitialized = true;
Promise.all([
loadScript(self, libUrl + '/webviewer.min.js')
])
.then(() => {
var myObj = {
libUrl: libUrl,
namespacePrefix: '',
};
var url = myfilesUrl + '/webviewer-demo-annotated.pdf';
const viewerElement = this.template.querySelector('div')
const viewer = new PDFTron.WebViewer({
path: libUrl, // path to the PDFTron 'lib' folder on your server
custom: JSON.stringify(myObj),
config: myfilesUrl + '/config_apex.js',
l: 'YOUR_LICENSE_KEY_HERE',
}, viewerElement);
viewerElement.addEventListener('ready', () => {
this.iframeWindow = viewerElement.querySelector('iframe').contentWindow;
})
})
.catch(console.error);
}
//.. other stuff
Then, all your custom WV code can go inside config_apex.js. See this guide for more info on config files.
We also have a sample of loading the library inside of salesforce. Note that this is sample uses PDFTron WebViewer and not PDF.js Express, but all the concepts are the same.
Please note that all this is due to browser restrictions and not PDF.js Express itself.
If you have any issues or any questions please let me know.