0

I want to have a link on my application which when clicked downloads a pdf file saved in the assets folder. When I am clicking the link it is downloading the pdf but on opening it, it is giving the error:

Failed to load pdf document.

<a class = "help-link" download="User-Guide-televiewer" target="_blank" href="/assets/televiewer-file.pdf">
    Help 
</a>
5
  • Please add the URL you are accessing the PDF from. Commented Jun 27, 2019 at 5:28
  • I have put the entire file in assets folder Commented Jun 27, 2019 at 5:29
  • Please show your code and the error you are getting Commented Jun 27, 2019 at 5:31
  • @ShilpiDhiman are you accessing the PDF file like assets/file.pdf Commented Jun 27, 2019 at 5:46
  • Your problem isn't very clear.If the download link works and the file makes it to your computer at that point it's something else entirely. Does the original version of the pdf open? Does your computer flag files downloaded as potentially not safe (Windows does this by default these days)? Are you setting the mime type correctly for the download link? There are many possible causes here.Once the file is downloaded it's not an Angular specific problem. And in general file transferring is outside Angular as well. You are just using the browsers file handling apis @ShilpiDhiman Commented Jun 27, 2019 at 7:23

1 Answer 1

1

I was manually creating the pdf file with .pdf extension. Nothing wrong with the code. Just the file error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.