Check out example codes for "pdfjs customizing viewer.html js event handler". It will help you in understanding the concepts better.

Code Example 1

<script>
  // add this script block to viewer.html (pdfjs/web/viewer.html)
  document.addEventListener('DOMContentLoaded', function() {
    console.log('DOMContentLoaded');
  }, true);

  document.addEventListener('webviewerloaded', function(e) {
    console.log('webviewerloaded');
  });
</script>

Learn ReactJs, React Native from akashmittal.com