Quantcast
Viewing all articles
Browse latest Browse all 104

How can I open a PDF file with FileReader and get the path? [duplicate]

I want to display a PDF file with the following code. So far everything works fine, the file 'Test.pdf' opens. Now I want to be able to select a file via an "File-Open" dialog.

I tried different approaches and was able to get a "file-open"-dialog to select a file. But I don't know how to open the file in the viewer.Can anyone help me with this?

How do I create the dialog and pass the file to the viewer?

<html><head></head><body><iframe id="viewer"></iframe><script>    page = 1;    let reader = new FileReader();    function updateViewerURL() {      let viewer = document.getElementById('viewer');      viewer.src = reader.result;    }    reader.addEventListener('load', updateViewerURL);    fetch('Test.pdf')      .then(response => response.blob())      .then(blob => {        reader.readAsDataURL(blob.slice(0, blob.size, 'application/pdf'));    });</script></body></html>

Viewing all articles
Browse latest Browse all 104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>