Homelab, Linux & ABAP (~˘▾˘)~
 

[PDF.js] Prevent loading default pdf

This can be done by appending ?file= to the src path, like it is mentionend here.

<!-- "?file=" prevents loading the default document -->
<iframe id="pdf-js-viewer" src="/pdf/web/viewer.html?file=" title="webviewer" frameborder="0" width="100%" height="700" allowfullscreen="" webkitallowfullscreen=""/>

Or by setting the variable defaultUrl to blank using the onload event.

pdfViewer = document.getElementById("pdf-js-viewer");

pdfViewer.onload = () => {
          pdfViewer.contentWindow.PDFViewerApplicationOptions.set(
            "defaultUrl",
            ""
          );
}; 

Leave a Reply

Your email address will not be published. Required fields are marked *