Downloading Pdf File Using HTML Code
Last Updated : Jul 1, 2023
In this tutorial we will show you the solution of downloading pdf file using HTML code, in HTML in previous sessions we will learn about anchor tag, pdf, images, videos and songs. And from all of these we learn about images only.
Like how we are able to download images in html. Now, today we will define you how you are able to make download the pdf file with the help of html. And this can be done here with the help of anchor tag.
Step By Step Guide On Downloading Pdf File Using HTML Code :-
As, there are many ways with the help of which you are able to make pdf download. As see in some website like school website and in some mobile applications also.
That there is a text or image for some and when you click on this link, the pdf or also images started downloading.
So, from with the help of anchor tag we will show you here that how you are able to make a pdf downloading in html codes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <a href="https://www.indiabudget.gov.in/economicsurvey/doc/echapter.pdf" download> click here to download pdf </a> <br> <a href="https://dpiit.gov.in/sites/default/files/incredible_india.pdf" download="download"> click here to download next pdf </a> </body> </html>
- First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
- Secondly, the <html> tag is used to indicate the beginning of an HTML document.
- As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
- Thirdly, <body> tag is used to define the webpage body. All the contents to show on website are written here. Hence, here we specify some ways with the help of which you are able to make pdf downloadable.
- First here we create an anchor tag and under this tag, we write text. You can also attach an image and something other on which you want to click.
- The concept is to add an attribute download before ending the opening tag of anchor tag. The download is an attribute and when you click on the link showed on browser. You are able to make a pdf downloadable.
- Where in second case, means in second anchor tag. We use the same process but here the download attribute gets changed.
- Here we use download attribute with some value and that is download again. It not matters that why we use download this as. But this is used to change the name of the file which we want to download.
- At last, the <body> and <html> tags are closed with </body> and </html> respectively.
At last, in conclusion here we want to say that there are many other ways with the help of which you are able make a pdf downloadable.
And one from them is with the help of anchor tag. I hope this tutorial on downloading pdf file using HTML code helps you.