I am experimenting with the pdf.js examples, and in particular the viewer.html/viewer.js. I am trying to access a URL outside of the webroot. My PHP installation has access to a specific folder outside webroot where I store pdf files. In PHP I stream these files to the browser for download, which works fine. However, I would like to also stream the file to the viewer directly. Is that possible?
So, for example, my URL would be /web/viewer.html?file=12345.pdf for a file that is accessible to the web browser. However, if I want to stream this from outside the root, the URL may look like this: /web/viewer.html?file=fetch.php?id=12345
Any idea how I should go about this, as the viewer seems to fetch the filename directly.
One idea I explored is to create a temporary copy within webroot. Pass that file to the viewer and delete the file after a set period to ensure it was loaded. That seems awfully inefficient, so somehow passing the file directly to the viewer so it can be used without creating a temp copy seems to be a better approach, if possible. Any ideas are much appreciated.