function download(pdfUrl, fileName) {
fetch(pdfUrl).then(resp => resp.arrayBuffer()).then(resp => {
const file = new Blob([resp], {type: 'application/pdf'});
const fileURL = URL.createObjectURL(file);
jQuery("#download-button-prev").attr('href', fileURL).attr('download', fileName);
});
}
download(linkUrl, docName);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter