search

Home  >  Q&A  >  body text

How to open a compressed PDF from a browser link?

<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粉546138344P粉546138344478 days ago696

reply all(1)I'll reply

  • P粉336536706

    P粉3365367062023-09-05 14:27:03

    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.

    reply
    0
  • Cancelreply