# PDF viewer of pdf js express throwing PDF header not found error(Uncaught(in promise)- type:InvalidPDF)

**URL:** <https://pdfjs.community/t/pdf-viewer-of-pdf-js-express-throwing-pdf-header-not-found-error-uncaught-in-promise-type-invalidpdf/2494>\
**Category:** Technical Support\
**Created:** [April 6, 2023, 9:06am UTC](https://pdfjs.community/t/pdf-viewer-of-pdf-js-express-throwing-pdf-header-not-found-error-uncaught-in-promise-type-invalidpdf/2494 "2023-04-06T09:06:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhilhill19](https://avatars.discourse-cdn.com/v4/letter/n/91b2a8/32.png) [@nikhilhill19](https://pdfjs.community/u/nikhilhill19)\
**Post date:** [April 6, 2023, 9:06am UTC](https://pdfjs.community/t/pdf-viewer-of-pdf-js-express-throwing-pdf-header-not-found-error-uncaught-in-promise-type-invalidpdf/2494/1 "2023-04-06T09:06:26Z")

</div>

**Which product are you using?**  
PDF.js Express Plus

**PDF.js Express Version**  
8.7.2

**Detailed description of issue**  
PDF is not rendering ,instead throwing error of:  
1)Exception: Message: PDF header not found.The file is not a valid PDF document.  
2)on console: Uncaught (in promise) :type: “InvalidPDF”

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/6/666580f64da45a5aaff8d4e6aa9429abc2d63a3d.png)

**Expected behaviour**  
{All pdf should render on our browser}

**Does your issue happen with every document, or just one?**  
{Every document}

**Link to document**  
{Present on local storage}

**Code snippet**  
BELOW IS THE CODE:  
import React from “react”;  
import WebViewer from “@pdftron/pdfjs-express”;  
export default function App() {  
const viewer = React.useRef(null);  
const funView = () =\> {  
WebViewer(  
{  
path: “WebViewer/lib”,  
initialDoc: “/files/demo.pdf”,  
extension: “pdf”,  
},  
viewer.current  
).then((instance) =\> {  
instance.UI.setTheme(“dark”);  
instance.UI.disableElements([“leftPanel”, “leftPanelButton”]);  
instance.Core.documentViewer.addEventListener(“documentLoaded”, () =\> {  
const rectangleAnnot =  
new instance.Core.Annotations.RectangleAnnotation();  
rectangleAnnot.PageNumber = 1;  
rectangleAnnot.X = 100;  
rectangleAnnot.Y = 150;  
rectangleAnnot.Width = 200;  
rectangleAnnot.Height = 50;  
instance.Core.annotationManager.addAnnotation(rectangleAnnot);  
});  
});  
};  
return (

  
\<button  
onClick={() =\> {  
funView();  
}}  
\>  
View  
  
\<div style={{ height: “auto”, overflowY: “auto” }}\>  
\<div  
className=“webviewer”  
style={{ height: “51em” }}  
ref={viewer}  
\>
  
  
  
);  
}

---

<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:** [April 6, 2023, 6:52pm UTC](https://pdfjs.community/t/pdf-viewer-of-pdf-js-express-throwing-pdf-header-not-found-error-uncaught-in-promise-type-invalidpdf/2494/2 "2023-04-06T18:52:01Z")

</div>

Hi nikhilhill19,

Looks like this may be a duplicate issue to the other forum post,  
Can you provide a sample project to reproduce?

Best regards,  
Tyler
