# Problem with initialization viewer

**URL:** <https://pdfjs.community/t/problem-with-initialization-viewer/825>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [June 16, 2021, 11:58am UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825 "2021-06-16T11:58:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukasz.konikiewicz](https://avatars.discourse-cdn.com/v4/letter/l/49beb7/32.png) [@lukasz.konikiewicz](https://pdfjs.community/u/lukasz.konikiewicz)\
**Post date:** [June 16, 2021, 11:58am UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/1 "2021-06-16T11:58:53Z")

</div>

**PDF.js Express Version**  
Probably 7.3.3. I’m not sure, because I cannot initialize viewer so I don’t get this info in console.

**Detailed description of issue**  
I get “Failed to load resource: the server responded with a status of 404” when I run my application.  
I assume that there’s some problems with accessing index.html with viewer.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/9c91912c5b6328127a582bb10a17fa1829c4e1a9.png)

Full error message:

Failed to load resource: the server responded with a status of 404 (Not Found)  
~/lib/pdfexpress/lib/ui/index.html#d=https%3A%2F%[2Fwww.w3.org](http://2Fwww.w3.org)%2FWAI%2FER%2Ftests%2Fxhtml%2Ftestfiles%2Fresources%2Fpdf%2Fdummy.pdf&a=1&filepicker=0&pdfnet=0&enableRedaction=0&enableMeasurement=0&pageHistory=1&notesInLeftPanel=0&singleServerMode=false&selectAnnotationOnCreation=0&id=1:

**Expected behaviour**  
Properly rendered viewer 🙂

**Does your issue happen with every document, or just one?**  
I tried document from url, and a few documents from my local files. Problem is the same for both cases.

**Link to document**  
{Provide a link to the document in question if possible}

**Code snippet**  
Code which i use to initialize viewer:

```javascript
<script src="~/lib/pdfexpress/lib/webviewer.min.js"></script>

                <div id="express_viewer"></div>

                <script>
                
                const viewer = document.getElementById("express_viewer");

                WebViewer({
                    path: '~/lib/pdfexpress/lib',
                  licenseKey: 'my license code here',
                  initialDoc: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
                }, viewer).then(instance => {
                    onReady();

                    const { docViewer } = instance;
                    docViewer.on('documentLoaded', onDocumentLoaded);
                  });

                  // Vanilla JS
                    const onReady = instance => {
                      // Executed when the viewer is ready
                      // NOTE: Document is not loaded yet
                      instance.enableFilePicker();
                    };

                </script>

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ffbcd25c7d423db8d5acd5db201c272f4db306dd.png) [@system](https://pdfjs.community/u/system)\
**Post date:** [June 16, 2021, 11:58am UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/2 "2021-06-16T11:58:58Z")

</div>

**Hello, I’m Ron, an automated tech support bot 🤖**

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:
- [Best practices for PDF.js Express - Preload the Web Viewer](https://pdfjs.express/documentation/learn-more/best-practices#preload-the-web-viewer)
- [Config files](https://pdfjs.express/documentation/learn-more/advanced/config-files)
- [Integrating Vue.js with PDF.js Express JavaScript PDF library - Sample overview](https://pdfjs.express/documentation/get-started/vue#sample-overview)

APIs:
- [CoreControls.Document - extractPDFNetLayersContext(layers)](https://pdfjs.express/api/CoreControls.Document.html#extractPDFNetLayersContext__anchor)
- [Adding a download button](https://pdfjs.express/api/utils/tutorial-Adding%20a%20download%20button.html#__anchor)
- [PDF.js Express Utilities](https://pdfjs.express/api/utils/index.html#__anchor)

Forums:
- [How do I set up the core for Advanced customization?](https://pdfjs.community/t/how-do-i-set-up-the-core-for-advanced-customization/226/1)
- [Support for Gatsby.js](https://pdfjs.community/t/support-for-gatsby-js/468/1)
- [Read S3 bucket private pdf file by checking S3 access key and secret key using PDF.js Express](https://pdfjs.community/t/read-s3-bucket-private-pdf-file-by-checking-s3-access-key-and-secret-key-using-pdf-js-express/151/1)

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 16, 2021, 2:46pm UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/3 "2021-06-16T14:46:11Z")

</div>

Hey there, this means that the path to your resources is incorrect. Please make sure that `path: '~/lib/pdfexpress/lib',` is correct. Also, try removing the `~` and using an absolute path.

Thanks!  
Logan

---

<div class="post-metadata">

**Author:** ![lukasz.konikiewicz](https://avatars.discourse-cdn.com/v4/letter/l/49beb7/32.png) [@lukasz.konikiewicz](https://pdfjs.community/u/lukasz.konikiewicz)\
**Post date:** [June 17, 2021, 6:46am UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/4 "2021-06-17T06:46:38Z")

</div>

Hey there,

“~” is equivalent of resource folder in my project.

I tried to change it to absolute path, but I have another error message.

This is my project structure:

![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/eada8d657f65e7c4f0c9cc080b71ba2a0edf8feb.png)

I used absolute path and now I get this error:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/717455d6a4f48b5dbfb2159a963f7c52adfd594d.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![lukasz.konikiewicz](https://avatars.discourse-cdn.com/v4/letter/l/49beb7/32.png) [@lukasz.konikiewicz](https://pdfjs.community/u/lukasz.konikiewicz)\
**Post date:** [June 17, 2021, 8:53am UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/5 "2021-06-17T08:53:21Z")

</div>

I also noticed there’s no problems with webviewer.min.js file, so I assume that ‘~/lib/pdfexpress/lib’ path is correct.

---

<div class="post-metadata">

**Author:** ![lukasz.konikiewicz](https://avatars.discourse-cdn.com/v4/letter/l/49beb7/32.png) [@lukasz.konikiewicz](https://pdfjs.community/u/lukasz.konikiewicz)\
**Post date:** [June 21, 2021, 7:59am UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/6 "2021-06-21T07:59:12Z")

</div>

Hi,

Can you help me somehow?

---

<div class="post-metadata">

**Author:** ![lukasz.konikiewicz](https://avatars.discourse-cdn.com/v4/letter/l/49beb7/32.png) [@lukasz.konikiewicz](https://pdfjs.community/u/lukasz.konikiewicz)\
**Post date:** [June 23, 2021, 1:28pm UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/7 "2021-06-23T13:28:55Z")

</div>

@Logan can you help me?  
I still didn’t manage to do that.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 23, 2021, 2:14pm UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/8 "2021-06-23T14:14:22Z")

</div>

Hi there,

This is very tough for me to debug as it is an issue with your environment. Are you able to send me a sample project where this is reproducable?

Thanks,  
Logan

---

<div class="post-metadata">

**Author:** ![lukasz.konikiewicz](https://avatars.discourse-cdn.com/v4/letter/l/49beb7/32.png) [@lukasz.konikiewicz](https://pdfjs.community/u/lukasz.konikiewicz)\
**Post date:** [June 25, 2021, 8:01am UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/9 "2021-06-25T08:01:06Z")

</div>

Hello @Logan

How can I sent you sample project?

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 25, 2021, 3:25pm UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/10 "2021-06-25T15:25:26Z")

</div>

Hi there!

The best way would be to zip up a minimal project where you can reproduce the problem.

Are you able to access `{your_local_url}/lib/pdfexpress/lib/ui/index.html` directly in your browser? At the end of the day this is an issue with your local environment and it seems like either `~/lib/pdfexpress/lib` is incorrect, or your server is not serving `/lib/pdfexpress/lib/ui/index.html` correctly.

Logan

---

<div class="post-metadata">

**Author:** ![red1.reachout](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@red1.reachout](https://pdfjs.community/u/red1.reachout)\
**Post date:** [September 7, 2023, 5:59am UTC](https://pdfjs.community/t/problem-with-initialization-viewer/825/11 "2023-09-07T05:59:22Z")

</div>

Hi Logan,

I’m encountering an issue with rendering a PDF in my Next.js project and it’s in the test path. I’ve sent you a zip file containing the project. If you could take a look and let me know where I might be making a mistake, it would be greatly appreciated.

[project.zip](https://pdfjs.community/uploads/short-url/chb9NITtujytgvSGVPQI1jS1uk3.zip) (4.2 MB)
