Html 用于下载 pdf 文件的按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33644219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 18:28:11  来源:igfitidea点击:

Button to Download a pdf file

htmlpdfbuttondownload

提问by Jo?o Guerreiro

I have a HTML button and I want it to download the pdf file by pressing it. Thank you

我有一个 HTML 按钮,我希望它通过按下它来下载 pdf 文件。谢谢

       <div class="columns download">
          <p>
             <a href="images/Portfolio.pdf" class="button"><i class="fa fa-download"></i>Download CV</a>
          </p>
       </div>

回答by Rakin

 <div class="columns download">
          <p>
             <a href="images/Portfolio.pdf" class="button" download><i class="fa fa-download"></i>Download CV</a>
          </p>
       </div>

回答by phaattran

The way to do that is to embed the button inside the a tag link.

这样做的方法是将按钮嵌入到 a 标签链接中。

<a href="./abcf32x.pdf" download="How-to-download-file.pdf">
    <button>Download File</button>
</a>