# Err\_content\_length\_mismatch

**URL:** <https://pdfjs.community/t/err-content-length-mismatch/2852>\
**Category:** Bug Reports\
**Created:** [September 25, 2023, 12:41pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852 "2023-09-25T12:41:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcelovtneves](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@marcelovtneves](https://pdfjs.community/u/marcelovtneves)\
**Post date:** [September 25, 2023, 12:41pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852/1 "2023-09-25T12:41:36Z")

</div>

I recive this error when i use [pdfjs.express](http://pdfjs.express) in chrome and on development mode  
i tried to disable hardle aceleration, but still doesn’t work  
My code:  
useEffect(() =\> {  
WebViewer(  
{  
path: ‘/webviewer/lib’,  
licenseKey: “mylicense”,  
},  
viewer.current  
).then((instance) =\> {  
setInstanceCurrent(instance)  
instance.Core.documentViewer.addEventListener(‘documentLoaded’, () =\> {  
setIsLoading(false)  
})  
instance.UI.iframeWindow.addEventListener(‘loaderror’, (err) =\> {  
console.log({ err })  
})  
instance.UI.setLanguage(‘pt\_br’)  
instance.UI.loadDocument(useBase64ToBlob(pdfBase64, ‘document’), {  
filename: `${fileName}.pdf`,  
})  
if (localStorage.getItem(‘themeMode’) === ‘light’) instance.UI.setTheme(‘light’)  
else instance.UI.setTheme(‘dark’)  
})  
}, )  
Error on console:  
webviewer-ui.min.js:1 Failed to load resource: net::ERR\_CONTENT\_LENGTH\_MISMATCH

---

<div class="post-metadata">

**Author:** ![ejohnson](https://avatars.discourse-cdn.com/v4/letter/e/a3d4f5/32.png) [@ejohnson](https://pdfjs.community/u/ejohnson)\
**Post date:** [September 25, 2023, 4:28pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852/2 "2023-09-25T16:28:19Z")

</div>

Thank you for posting the incident to our forum. We will provide you with an update as soon as possible.

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [September 25, 2023, 7:42pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852/3 "2023-09-25T19:42:42Z")

</div>

Hi there,

You code appears to be incomplete, for example, the useBase64ToBlob function is missing. Could you please provide all the code necessary to run the project?

Does this issue only occur with specific PDFs or all PDFs? If specific ones, please provide a sample PDF and screenshots of the errors.

Best Regards,  
Darian

---

<div class="post-metadata">

**Author:** ![marcelovtneves](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@marcelovtneves](https://pdfjs.community/u/marcelovtneves)\
**Post date:** [October 31, 2023, 1:54pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852/4 "2023-10-31T13:54:31Z")

</div>

```tsx
export const useBase64ToBlob = (base64Data, fileName: string) => {
  const decodedData = atob(base64Data)
  const byteNumbers = new Array(decodedData.length)
  for (let i = 0; i < decodedData.length; i++) {
    byteNumbers[i] = decodedData.charCodeAt(i)
  }
  const byteArray = new Uint8Array(byteNumbers)
  const blob = new Blob([byteArray], { type: 'application/pdf' })
  return new File([blob], fileName, { type: blob.type })
}

```

occur with all PDFs the webviewer doesn’t load and the code inside .then((instance)=\>{}) doesn’t run

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [October 31, 2023, 7:10pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852/5 "2023-10-31T19:10:28Z")

</div>

Hi there,

Do you have any example base64Data? Does this happen if you try to load a normal PDF without using the useBase64ToBlob function? Are you currently using v8.7.4?

If possible, could you upload your project to GitHub so we can take a closer look?

Best Regards,  
Darian

---

<div class="post-metadata">

**Author:** ![marcelovtneves](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@marcelovtneves](https://pdfjs.community/u/marcelovtneves)\
**Post date:** [October 31, 2023, 8:03pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852/6 "2023-10-31T20:03:32Z")

</div>

Unfortunately I can’t post to github, but this issue is occurring without useBase64ToBlob as well. but if you run the same code with the same pdf in production it works.  
When production finishes rendering the component, I receive this table

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/4/44c7aa37d5c3cfec8ee30c054027514b3054b6c7.png)  
I’m not getting this table on localhost

---

<div class="post-metadata">

**Author:** ![marcelovtneves](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@marcelovtneves](https://pdfjs.community/u/marcelovtneves)\
**Post date:** [October 31, 2023, 8:09pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852/7 "2023-10-31T20:09:38Z")

</div>

Is there any way to debug the WebViewer instance before .then()?

---

<div class="post-metadata">

**Author:** ![darian.chen](https://avatars.discourse-cdn.com/v4/letter/d/3d9bf3/32.png) [@darian.chen](https://pdfjs.community/u/darian.chen)\
**Post date:** [November 3, 2023, 7:15pm UTC](https://pdfjs.community/t/err-content-length-mismatch/2852/8 "2023-11-03T19:15:05Z")

</div>

Hi there,

It is difficult to find the cause of the problem without a way to reproduce the issue. Please considering providing a sample project where the issue is reproducible. Have you tried deleting the core and ui folders and reinstalling? Please try deleting your cache and updating Chrome.

Does this happen on other browsers?

I don’t believe there is a way to debug the instance before .then.

Best Regards,  
Darian
