You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to embedded pdf on my html page using pdf.js, with the help of pdf viewer blog,I have included pdf.js and pdf.worker.js in my html file, but when I open the page, nothing is embedded and I am getting below error. Cannot read property firstElementChild of null
Man you miss a focal point:
"Include viewer.html using SSI or your favorite templating system."
SSI means server side including, the content of viewer.html should be in the page before calling window.PDFJS.webViewerLoad.
You don't need SSI, you can use jquery too.
ex:
<script>
var file = 'some-document.pdf';
// waiting for page load, loading the content of viewer.html inside pdfjs THEN load file
$(function()
{
$('div.pdfjs').load("bower_components/pdf.js-viewer/viewer.html", function()
{
window.PDFJS.webViewerLoad();
window.PDFViewerApplication.open(file);
});
});
</script>
I am trying to embedded pdf on my html page using pdf.js, with the help of pdf viewer blog,I have included pdf.js and pdf.worker.js in my html file, but when I open the page, nothing is embedded and I am getting below error.
Cannot read property firstElementChild of null
Please help me in this.
Thanks!
HTML Code:
Checkout below error:
Uncaught (in promise) TypeError: Cannot read property 'firstElementChild' of null at Object.PDFViewer (http://url/pdf.js:17939:52) at http://url/pdf.js:12985:21 at Object._initializeViewerComponents (http://url/pdf.js:12973:10) at http://url/pdf.js:12884:16PDFViewer
The text was updated successfully, but these errors were encountered: