How to open a compressed PDF from a browser link?
P粉546138344
P粉546138344 2023-09-04 21:10:37
0
1
691
<p>Using MS Edge browser on Windows 11... I have a directory with three PDF files, two of which are inside a zip file: </p> <ul> <li>File1.pdf</li> <li>myfile.zip/file2.pdf</li> <li>myfile.zip/file3.pdf</li> </ul> <p>I want to access this content from a static HTML page. Similar to...</p> <pre class="brush:php;toolbar:false;"><a href="file1.pdf" target="_new1">file1</a> <a href="myfile.zip\file2.pdf" target="_new2">file2</a> <a href="myfile.zip\file3.pdf" target="_new3">file3</a></pre> <p>Apparently, while the first link works, the other two don't. Is there a way to do this? </p> <p> (Note: This is not my regular skill area. So, please answer "semi-new".) </p> <p>Update: I did simplify the scenario to make the problem simpler. In fact, there are over 1000 PDFs in the directory tree (some in ZIPS, some not). These may all be updated on an ad hoc basis by external processes. If that's not the case, then yes, simply unzipping everything would be the easiest way. Maybe the best solution would be to periodically scan the directory for changed ZIPs and unzip any newer ZIPs... but I'd like to see if there's a better way: direct access (if possible) or some way to click JIT decompression at link time. </p>
P粉546138344
P粉546138344

reply all(1)
P粉336536706

ZIP files are not directories, but files themselves.

It is strongly recommended that you unzip the ZIP file into a folder. For example, you can unzip myfile.zip to the myfile directory on your server and then use the following code:

<a href="file1.pdf" target="_new1">file1</a>
<a href="myfile\file2.pdf" target="_new2">file2</a>
<a href="myfile\file3.pdf" target="_new3">file3</a>

If you are unwilling to do this, you can try using a Javascript library to decompress the file. I searched online and found this: JSZIP

You can try reading the documentation and adding JavaScript to your HTML to extract the ZIP file you can get.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template