# A license key is required to use the view only build of PDF.js Express

**URL:** <https://pdfjs.community/t/a-license-key-is-required-to-use-the-view-only-build-of-pdf-js-express/3376>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [July 31, 2024, 7:56pm UTC](https://pdfjs.community/t/a-license-key-is-required-to-use-the-view-only-build-of-pdf-js-express/3376 "2024-07-31T19:56:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![afuller](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@afuller](https://pdfjs.community/u/afuller)\
**Post date:** [July 31, 2024, 7:56pm UTC](https://pdfjs.community/t/a-license-key-is-required-to-use-the-view-only-build-of-pdf-js-express/3376/1 "2024-07-31T19:56:46Z")

</div>

**Which product are you using?**  
PDF.js Express Viewer. From the `package.json` file:

```javascript
  "name": "@pdftron/pdfjs-express-viewer",
  "description": "PDFJS Express",
  "version": "8.7.5",
  "main": "lib/webviewer.min.js",

```

**PDF.js Express Version**

```javascript
|UI version|'8.7.0'|
|---|---|
|Core version|'8.7.5'|
|webviewer.min.js|'8.7.5'|
|Build|'Ny80LzIwMjR8MzMxOTBmNGM5YQ=='|
|WebViewer Server|false|
|Full API|false|

```

**Detailed description of issue**  
Strictly using the example code in the manual integration section ([PDF.js Express Viewer Download & Integration | Documentation](https://pdfjs.express/documentation/get-started-viewer/manually)), the js console constantly complains about the license key:

```javascript
PDFJSDocumentType.js:118 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:119 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)
    at error (PDFJSDocumentType.js:119:1)
    at PDFJSDocumentType.js:2697:417

```

The viewer itself loads. After a second, however, it goes gray with a circle in the middle. This is on a server that’s in a subdomain of the one the license key has been issued for.

**Expected behaviour**  
Expected behavior is that the PDF loads in the window and no license key errors in the console.

**Does your issue happen with every document, or just one?**  
All documents, even the sample ones provided in the documentation’s sample code.

**Link to document**

**Code snippet**

```javascript
<div id='viewer' style="width:1024px;height:600px;margin:0 auto"></div>
<script>
  WebViewer({
    path: '/js/pdfjsexpress/lib',
    licenseKey: '--removed--',
    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>    

```

 ![Screenshot (114)](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/0/03ba39d12a6dfaacaa4073ce47913333ace3e64a.png)

---

<div class="post-metadata">

**Author:** ![afuller](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@afuller](https://pdfjs.community/u/afuller)\
**Post date:** [August 1, 2024, 2:02pm UTC](https://pdfjs.community/t/a-license-key-is-required-to-use-the-view-only-build-of-pdf-js-express/3376/3 "2024-08-01T14:02:12Z")

</div>

An update with no solution in sight: I’ve replaced the PDF.js Express viewer code with that downloaded from here: [https://pdfjs.express/download-viewer](https://pdfjs.express/download-viewer) and flushed all the caches wherever they might be. I’ve also created a new license key for the subdomain in question. I’ve also also moved the code around to different servers that I know are accessible from the internet. None of this has helped.

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [August 6, 2024, 7:39pm UTC](https://pdfjs.community/t/a-license-key-is-required-to-use-the-view-only-build-of-pdf-js-express/3376/4 "2024-08-06T19:39:14Z")

</div>

Hello afuller,

It looks like the testing environment included is causing this, if you only remove the code from the sample so it looks like this:

viewing sample:

```javascript
WebViewer(
  {
    path: '../../../lib',
    enableFilePicker: true,
    licenseKey: "key",
    initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
  },
  document.getElementById('viewer')
).then(instance => {

});

```

There is no error and the product works as expected.

Best regards,  
Tyler
