Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a link to download a pdf file nuxt?

I just wants to add a link to download a pdf file in nuxt project.

How do I do that?

I have tried the following:

<a :href="require('@/static/documents/WTSDL2019_Pamplet.pdf')" download class="btn btn-sm btn-sub-color" >Download</a>

which works well for images but not for pdf files. I found vue-pdf but I feel its an extra work for the purpose of just linking a pdf file. I have no work view a pdf files with all those events.

like image 457
David Avatar asked Jul 01 '19 05:07

David


2 Answers

I had the same problem and this worked for me. I added the file in the static folder and it worked.

  • static

    • WTSDL2019_Pamplet.pdf
<a href="/WTSDL2019_Pamplet.pdf" download="">Download</a>
like image 117
Mohamed Ayman Avatar answered Oct 23 '22 06:10

Mohamed Ayman


This works:

<a href="/cv.pdf">Download my CV</a>
 

if you put the PDF in the static folder. You don't need the /static/ as NUXT does the magic.

like image 3
Gabriel Avatar answered Oct 23 '22 07:10

Gabriel