I haven't tried this but, just wondering if could it be done in javascript?
For example.....
const downloadLink = document.createElement('a');
downloadLink.href = 'http://www.mydomain.com/samples/mypdf.pdf';
downloadLink.download = 'mypdf.pdf';
downloadLink.textContent = 'Download PDF';
document.body.appendChild(downloadLink);
Replacing url and file names with tags?