How to create a button that downloads a PDF file

Hi all, how would I go about creating a button that downloads a PDF file automatically?
Would I have to do this as an HTML widget? Please help.

Easiest way about going about that is uploading your desired PDF onto your server - then get that URL link and direct your button to open it?

Does this make sense?

1 Like

You can also link to a file on Dropbox. I have a button saying something like “download price list” which links to the pdf file stored on my Dropbox. This way I don’t have to remember to upload it if the site is updated.

I did as @Mario described at the bottom of this page (CAD download)
Decide if it should open in a new window (recommended)
Andy

www.apswoodwork.uk

2 Likes

Hello all, my name is Rob and i am new at this community/forum. I’m Dutch, I live in Italy (in the Langhe region, Piedmont) and my English is not so good but do my best. With a little help from Google translate, I hope you can understand me.

I love the app but for now i am learning, trying and reading on this community for when i have to make my new site. The app is already very promising with every time all the new updates. When you blink your eyes Blocs is already better.

Now my question. When you want to make a .gpx file downloadable from your website what code do jou have to use then and where do you place it. The .gpx file is then already placed in the same folder as the page’s HTML file. I have an example at the bottom of this page. (the tracks)

If everyone is already in the Christmas mood please let me know after Christmas. For everyone a couple of nice days.

Rob

Hi,
I have a downloadable pdf on my site but I am sure it could be any file type.
On the blocs page there is a button to click to download this file. The button has the Interaction - Navigate to URL and the URL is the location of the file. In my case I have it stored on Dropbox. Right click the file on Dropbox and Copy Dropbox Link - this can then be pasted into the URL field in the Interactions panel. Change the zero at the end to a 1 and it will download immediately when clicked.
Hope this helps

1 Like

Thanks for the reply Anthony. First i tried it your way. Stored the .GPX file on Dropbox and used the link. When a visitor click on te link then the window opens and you can download the file from Dropbox. This is the first thing how i don’t want to see this. I like it like this. Not how it looks but the way the .GPX file can be downloaded. That when you click it you directly download it to your computer. Ones the .GPX file is in your download map and you click the file the file opens in Garmin Basecamp. The second thing is that when i download the .GPX file from Dropbox i get the file like a .txt file and i tried it also on another way and this time i could only open it in Fraise (or another text editor)

The next time when i make my site all over again in Blocs i really want to make it like this. I did make this website in Freeway 7 and there i used an “action” called the “Force download (PHP)” action. As some of you know Freeway (SoftPress) is stopped and find in Blocs a great and easy alternative. It works great and looks beautiful. However, I still have to learn a lot and not everything is still possible, but when I see how hard Norm is working on this program i think everything is possible in the future with Blocs. Well, almost everything.:wink:

And perhaps it is also possible to make this downloadable link very easy. It will probably can only do not know how yet.

Have a nice Christmas all,
Rob

Hi Rob,
have you changed the dl=0 for dl=1 at the end of the link you copied from Dropbox? This makes the file download as soon as the button is clicked.

Merry Christmas.

1 Like

Hi Anthony,

Thank you for have to look at it and dl=0 to dl=1 works perfectly. Sadly not with a .gpx file. Instead of a .gpx file I get a .gpx.txt file from Dropbox which you can not use in Garmin BaseCamp. I’ve also tried with a .pdf file and that works perfectly well. Anyway i have learned something and got a step closer. Thank you Anthony and a merry Christmas to you to.
Rob

Just tried the test and it downloads a .gpx file 36.16kb in size on my phone. I have not opened it but it just has the filename EscursionAllaPra.gpx
I can’t understand why it won’t work correctly on your machine but hope this info helps a bit. Anthony.

EDIT: Just tried in Safari on my Mac and I too get the .txt on the file but it downloads OK in Firefox on Mac and also on my Android phone.

It’s possibly related to browser choice, available plugins and options for how different file formats are treated. It’s beyond your control though how somebody else has their computer and browser set up.

Hello Anthony

Sorry that I have not tried it out in other browsers because now i see in Crome and Firefox it works well. When I want to download a .gpx file from my old site, created in Freeway Pro, it works well. The settings on my browser Safari are still the same then. It will then something to do with the “Force download (PHP)” action that I have used there. It may be possible that thats the reason the .gpx file can be downloaded in any browser. Who wants to take a look at it can download it from Dropbox. I don’t understand a lot of code. Thanks guys, thanks to you and the community I am getting wiser by the day.

Rob

And of course it must be something with my settings on my browser. Have anyone a suggestion? I use Safari Versie 10.0.1

A better way to handle downloads is with a PHP script. This is what the action in Freeway was uploading and using.

This would make it browser agnostic, among other advantages such as logging and preventing other sites from linking to your files.

At that point Freeway made it me very easily with its “Force download (PHP)” action. But how do I realize that Blocs? I used the action in Freeway but do not know how it worked, except that it worked well. I’ve tried some things and with some results I can live with but as you say, ScottinPollock, a .php script would be better.

Does anyone know how? And … it is (already) possible Blocs?

Ciao, Rob

Give me a few minutes…

This should do what you want…

http://www.zubrag.com/scripts/download.php

Thank you for your trouble ScottinPollock but from code I really know too little. What do I have to change in the download link? Can i put te link from Dropbox in there aswel? And do i place this link at “Interactions”> navigate to URL? And the ”download.php" file, where do I put that? And should I make some changes in there aswel? I know, to many questions but if someone has the patience to help me, I would like to try it if I succeed.

The download.php file goes on your web server. And you will need to create a folder on your server that contains the files you want to offer for download (no dropbox required).

And yes, you will need to make some edits to download.php. If you open the php file with a text editor, you’ll find instructions on how to set up four ‘defines’ on lines 15 through 28. Once that is done, you call the script from your button using the navigate to url interaction in Blocs. The download url would look something like:

http://yoursite.com/download.php?f=yourFileName.pdf

BTW, if you want to enable the logging, be sure to set write permission for the log file on your server.

Thank you ScottinPollock but I’m still not at that level. I’m still at level Dummies. (and with Dummies is nothing wrong by the way :wink:) The download URL i think i understand. And in the download.php, the directory where you keep all files for download. Perhaps, but “Empty - allow hotlinking”, "ALLOWED_REFERRER ‘,’ ') ?, and log downloads? true / false define ( ‘LOG_DOWNLOADS’, true); and “// log filename define ( ‘log_file’ ‘downloads.log’);” ?? Yes of course.:dizzy_face:

Let’s just say i’m not ready for this, it is just too much for now. It is of course difficult to explain when it is a piece of cake for the most here. For now I just need to recognize that I have to keep it simple. I just need to start with something simpler until I understand more of code.

Again, thanks for trying to help me out.
Rob