Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
UI version | ‘8.4.1’ |
---|---|
Core version | ‘8.4.0’ |
Build | ‘NC8xMi8yMDIyfDRkZTU3MmExYg==’ |
WebViewer Server | false |
Full API | false |
Detailed description of issue
{Description here}
I have the followed the setup for a viewer but no matter what I do I keep getting asked for a license key. I am using a license key as I will show in the code section.
I have taken the the zip file from the download page:
- Unzipped it
- npm install
- npm serve
- put my license key into the viewing.js file
- It works
- Move all the same code into my project and it doesn’t work because its looking for the license key.
I have also tried to do the install as shown on the manual integration getting started page:
Expected behaviour
{Provide a screenshot or description of the expected behaviour}
I am expecting the license key to be read and used for my local domain (example.test). I have created a license key for the domain example.test incase it was not recognised as a local setup.
Does your issue happen with every document, or just one?
{Answer here}
The viewer has not loaded for me as yet.
Link to document
{Provide a link to the document in question if possible}
n/a
Code snippet
{Provide a relevant code snippet}
**Note that I am using the full correct license key from the PDF.js Express page. I just removed it for the code below
<head>
<script src="/js/PDFJSExpress/lib/webviewer.min.js"></script>
</head>
<body>
<div id="viewer"></div>
<body>
<script>
WebViewer({
path: '/js/PDFJSExpress/lib', // path to the PDF.js Express'lib' folder on your server
licenseKey: XXXHRt',
initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
}, 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>