Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
|UI version|‘8.2.0’|
|Core version|‘8.2.1’|
|Build|‘MS8yMC8yMDIyfGYyZTU5NTU0YQ==’|
Detailed description of issue
The PDF Viewer loads on the page, but doesn’t open the document; it only shows a greyish overlay with the circle in the middle. The browser’s console shows the following errors:
PDFJSDocumentType.js:104 A license key is required to use the view only build of PDF.js Express. Get your free license key at https://pdfjs.express/profile (account required)
PDFJSDocumentType.js:104 Uncaught (in promise) Error: A license key is required to use the view only build of PDF.js Express. Get your free license key at https://pdfjs.express/profile (account required)
I have a valid key and I entered it in my code, which is the same code as the one in the documentation for manual implementation.
I tried this first using my local environment and online, but I get the same license key error. My issue is the same as the one indicated here: Pdfjs.express 8.2.1 error on a valid License Key
But I don’t see the solution for this closed request.
Thanks,
Expected behaviour
Display PDF document
Does your issue happen with every document, or just one?
Every document
Link to document
{Provide a link to the document in question if possible}
Code snippet
<script>
WebViewer({
path: '/wp-content/themes/mytheme/src/js/WebViewer/lib', // path to the PDF.js Express'lib' folder on your server
licenseKey: 'CEAAm...MKVy',
initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
// initialDoc: '/path/to/my/file.pdf', // You can also use documents on your server
}, document.getElementById('viewer'))
.then(instance => {
// now you can access APIs through the WebViewer instance
const { Core, UI } = instance;
// adding an event listener for when a document is loaded
Core.documentViewer.addEventListener('documentLoaded', () => {
console.log('document loaded');
});
// adding an event listener for when the page number has changed
Core.documentViewer.addEventListener('pageNumberUpdated', (pageNumber) => {
console.log(`Page number is: ${pageNumber}`);
});
});
</script>