skip to Main Content

Using the MS Edge browser on Windows 11 … I have a directory with three PDF files, two of which are inside a zip file:

  • file1.pdf
  • myfile.zip/file2.pdf
  • myfile.zip/file3.pdf

I want to access these from a static HTML page. Something like …

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

Obviously, while the first link works, the other two don’t. Is there a way to do this?

(Note: This isn’t my regular skill area. So, ‘semi-newbie’ answers, please.)

UPDATE: I did simplify the scenario to keep the question simple. Actually, there are over 1000 PDFs in a directory tree (some in ZIPS, some not). These are all subject to being updated by an external process on an ad-hoc basis. If not for that then, yes, simply unzipping everything would be the easiest approach. Maybe the best solution is to routinely scan the directories for changed ZIPs and unzip any updated ones … but I wanted to see if there was a better way: either access directly (if possible) or some sort of JIT unzip when a link is clicked.

2

Answers


  1. A ZIP file is not a directory, but is a file itself.

    It is highly recommended that you unzip the ZIP file to a folder. For example, you may extract the myfile.zip to a directory myfile on your server then use codes like:

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

    And if you JUST won’t do that, you may try using a Javascript library to unzip files. I searched the Internet and found this one:
    JSZIP

    You may try reading the documentation and add a Javascript to your HTML to extract the ZIP file you can get.

    Login or Signup to reply.
  2. Edge is generally restricted in what it can do with secured files thus you cannot address a zips contents directly but you may address a zip folder.

    However that folder if its a zip will be treated as a download and then the cached file will be opened. BUT again be restricted in what is allowed. For example the user may copy and paste to another folder (unzipped of course).

    enter image description here

    what can you do to view a file in a zip is thus constrained to what you may run in a shell script (i.e. possible from a HTA web page)

    to view a pdf from a zip you need vbsjsps1cmdbatscripts along the lines of

    if not exist %temp%newbe md %temp%newbe
    cd /d %temp%newbe
    
    tar -xf "C:long path toexample.zip"
    
    for blah blah "%temp%newbe*.PDF" do select one to view
    
    for selected do "C:Program Files (x86)MicrosoftEdgeApplicationmsedge.exe" --app="%temp%newbeselected.pdf"
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search