PDF download - odd behavior in Windows 10


#1

Hello Hype Community!
We have been using the code below in the inner HTML of a button to automatically download a PDF.

<a href="${resourcesFolderName}/PDFname.pdf" download=""><div style="width:100%;height:100%;"></div></a>

Works great except in Windows 10 (with Chrome) where on click to download the Hype document resets back to start (away from page they have navigated to)…

Anyone have similar issues?


#2

Do you have the link open in a new window? There might be an overzealous popup blocker restricting the download. (Disabling that might be something to try).

You might want to switch to this format: Click to download a PDF in resources library


#3

Thanks @Daniel - I have the code:
<a href="${resourcesFolderName}/poem_for_proxy_completion.pdf" download=""><div style="width:100%;height:100%;"></div></a>
in the inner HTML so not sure where it sets to open as separate or same window…?

I have used the format you provided the link for - but that doesn’t automatically download the PDF - rather it shows the PDF first before and then provides the option to save / print etc.


(Loves Hype) #4

Basically you need to manipulate the Mime-Type (but that is a server setting and not on the side of Hype).

.htaccess on the server (assuming apache as a server, attention affects all PDF on the folder)

<FilesMatch "\.pdf$">
ForceType applicaton/octet-stream
Header set Content-Disposition attachment
</FilesMatch>

If that isn’t an option then you can add the attribute “download” to the anchor-tag but the support is not across all browsers: https://caniuse.com/#search=download and https://www.w3schools.com/tags/att_a_download.asp


(Loves Hype) #5

Another option if your on a LAMP-Server or a server that at least runs PHP: