WoodRobot
WoodRobot

Reputation: 71

Linking to a pdf file with html

<a href="Resources/path.pdf">LINK </a>

Here is my link I'm keeping my pdf file (path.pdf) in the resources folder and am trying to click this link to open the pdf. When I click it while running local the error is " Your file was not found It may have been moved or deleted."

It's clearly there. ive checked, spell checked, and tried changing the location of the pdf file. HTML pages link just fine.

Thanks

Upvotes: 7

Views: 105429

Answers (3)

Daniel
Daniel

Reputation: 73

Though not necessary for user interaction, you may consider adding these attributes to your "a" tag, to tell search engines what the link is for:

  • "type" = "application/pdf"
  • "rel" = "alternate" (if the linked pdf contains the same content as the linking page)
  • "media" = "print" (if the linked PDF is primarily used for printing)

Example:

<a href="./pdfFile.pdf" target="_blank" type="application/pdf" rel="alternate" media="print">...</a>

Learn more about "a" tag attributes on W3Schools

Upvotes: -2

AL Mahmud
AL Mahmud

Reputation: 123

If you use local host you can use

<a href="./pdfFile.pdf" target="blank">PdfFile</a>

it will open new tab in you brower and starts to download the file.

If you hosting like netlify

<a href="./pdfFile.pdf" target="blank">PdfFile</a>

It will open a new tab showing your pdf file.

Upvotes: 0

centanomics
centanomics

Reputation: 119

Since you have not clarified for us whether you are using a local host or just viewing the text file in the browser I will assume the latter.

In this case, you would have your anchor tag and in the href attribute put the location of the file

<a href="C:\Users\Shannon Myers\Documents\Biology-DNA\teen_time_report.pdf">ok</a>

In the above example I started from my C: drive and went from there. Also you could do it as follows:

<a href="Resources\teen_time_report.pdf">ok</a>

This should link to the pdf file that you have in mind, as long as the resources folder and html file are in the same folder.

Upvotes: 11

Related Questions