I had to force the name of a PDF generated by the browser, so I picked up the solution in Can I set the filename of a PDF object displayed in Chrome?
Basically, a service worker intercepts a POST request with the content of the generated PDF, store it with the Cache API, and on GET with a crafted URL, it serves it.
It works perfectly for displaying the PDF. I am even able to print it. But when clicking the save button, after selecting the destination directory, Chrome says that it can't download the file with something like 404.
- In the service worker debugger, the code is not called on download.
- Using Wireshark, I see that no request is made
- Using a test site http://www.orimi.com/pdf-test.pdf I can confirm that after displaying, Chrome doesn't make a request before saving the file.
Of course, the behavior is the same in Edge. Of course, Firefox internal PDF.js handles this perfectly, and the file is saved.
Is there any reason for not getting the file?