How to download multiple pdfs in a zip?
See original GitHub issueHi! Thanks for creating this awesome library I’m struggling with replacing JSZip with your library I need to download several files in an array like this
exampleFiles = [
{
name: "1.pdf",
url: "/storage/files/1.pdf'
},
{
name: "hello.pdf",
url: "/storage/files/hello.pdf'
},
{
name: "abcd.pdf",
url: "/storage/files/abcd.pdf'
},
]
// this function is a layer of abstraction to download files
// it uses JSZip to fetch the remote files and download them
// in a zip archive. More important, it works well!
downloadFilesInZip(files)
Can you help me implement this using your library? I’ve tried to do it following the code provided in the README, but it seems like the fetch api gets the binary content of the pdf and it is saved as plain text; therefore I can’t display the file after downloading the zip
Thanks in advance
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
javascript - Zipping multiple PDFs and downloading the zip file?
If someone had the same issue, this is how I resolved it: var filename = url.replace(/.*\//g, ""); zip.file(filename, data, { binary: true, ...
Read more >Extracting Zip Files and Printing Multiple PDF Files - YouTube
This is a quick video on how to extract . zip files in Windows, as well as how to print multiple PDF files...
Read more >Download multiple PDF Report as Zip using ZipAchive in ASP ...
So I currently have all my PDF records being put in a zip fileEach record that is selected is put into a single...
Read more >Download multiple PDFs as a zip archive [#2672576] - Drupal
Downloading PDF's via an action plugin which gives us VBO integration is possible since [#2668482] but that downloads multiple entities onto ...
Read more >How to convert ZIP to PDF files or combine into one PDF?
And PDF Converter makes it simple and quick to combine such documents into one PDF file, in a click. All you need to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @myeongwooni. Yes, you can yield objects with
name
,lastModified
andinput
properties instead of just the Response. For example, if you want sequential filenames and you know all the files are plain text :Of course you might need more logic there to compute appropriate filenames. You have access to the whole Response for that. It’s how client-zip does it by default when you just pass it a Response: it looks at the response headers (specifically the Content-Disposition header if present ; if not, it will use the last part of the URL’s pathname).
Hello. You can’t specify “url” in the input for
downloadZip
and it’s not something I want to support. The reason for that is because fetching resources can be quite complicated (what if you need a JWT to access the PDFs, for example ?) and this library doesn’t want to be complicated.But, it’s really quite easy to fetch the resources and generate a correct input for
downloadZip
. The quick-and-slightly-inefficient way is this :You don’t even need to provide a “name” for your files because client-zip will extract the file name from the URL (or the Content-Disposition HTTP header) when you provide a Response object as input.
It’s slightly inefficient because the browser will start all the HTTP requests for the PDFs immediately. If you have a lot of PDFs to download, it would be better to download them in sequence using an async generator :
The difference there is that each download is started only when the previous file is completely copied to the ZIP archive.