Err_content_length_mismatch

I recive this error when i use 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

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

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

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

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

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


I’m not getting this table on localhost

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

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