# TypeError: Cannot read property 'nativeElement' of undefined

**URL:** <https://pdfjs.community/t/typeerror-cannot-read-property-nativeelement-of-undefined/329>\
**Category:** Technical Support\
**Created:** [October 12, 2020, 11:52am UTC](https://pdfjs.community/t/typeerror-cannot-read-property-nativeelement-of-undefined/329 "2020-10-12T11:52:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![himani.sharma](https://avatars.discourse-cdn.com/v4/letter/h/e47774/32.png) [@himani.sharma](https://pdfjs.community/u/himani.sharma)\
**Post date:** [October 12, 2020, 11:52am UTC](https://pdfjs.community/t/typeerror-cannot-read-property-nativeelement-of-undefined/329/1 "2020-10-12T11:52:55Z")

</div>

**PDF.js Express Version**

**Detailed description of issue**  
On loading pdf js express viewer element we are getting an error.

**Expected behaviour**  
{Provide a screenshot or description of the expected behaviour}

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

**Code snippet**

 ![]()

@ViewChild(‘viewer’, { static: true }) viewer: ElementRef;  
WebViewer({  
disableFlattenedAnnotations: true,  
path: ‘…/…/wv-resources/lib’,  
config: ‘…/…/wv-resources/lib/ui/config/file.js’, // relative to your HTML file  
disabledElements: [  
‘selectToolButton’, ‘toolbarGroup-Edit’, ‘toolsHeader’, ‘searchButton’, ‘header’,  
‘panToolButton’, ‘toggleNotesButton’, ‘notesPanel’, ‘menuButton’, ‘highlightToolGroupButton’, ‘underlineToolGroupButton’, ‘strikeoutToolGroupButton’, ‘stickyToolGroupButton’, ‘freeHandToolGroupButton’,  
‘toolsOverlay’, ‘viewControlsButton’, ‘leftPanelButton’, ‘toolbarGroup-Insert’, ‘toolbarGroup-Shapes’, ‘squigglyToolGroupButton’, ‘freeTextToolGroupButton’,  
],  
initialDoc: ‘assets/schedules-pdf/sample\_01.pdf’

```
}, this.viewer.nativeElement).then(instance => {

  const utils = new ExpressUtils();

  const { Annotations, Tools, annotManager, docViewer } = instance;
  // set pdf to full width of viewer
  instance.setFitMode(instance.FitMode.FitWidth);
})
```

---

<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:** [October 14, 2020, 2:10pm UTC](https://pdfjs.community/t/typeerror-cannot-read-property-nativeelement-of-undefined/329/2 "2020-10-14T14:10:16Z")

</div>

Hi there!

The error suggests that `this.viewer` is undefined. This would be an error in your code and not related to PDF.js Express, so unfortunately I cannot be of much help here.

Thanks!  
Logan

---

<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:** [October 14, 2020, 2:10pm UTC](https://pdfjs.community/t/typeerror-cannot-read-property-nativeelement-of-undefined/329/3 "2020-10-14T14:10:18Z")

</div>

Closed on October 14, 2020, 2:10pm UTC


