You need to sign in to do that
Don't have an account?
Veenesh Vikram
Force Download a Static PDF document from a button click
How can we "Force Download" a static PDF File stored as a Static Resource/Document in a VF Page? By Force Download, I mean that the File shoulld be downloaded straight away to the user's local machine and not open in a new Tab as a PDF.
Try this below may be you can change the styling later
<a href="/servlet/servlet.FileDownload?file={!attachmentInstance.Id}" target="_blank" styleClass="btn">Download</a>
It will try to open your document in a new tab. If it is image/pdf that can be opened in browser, it will open in new tab, otherwise it will download the file. Basically it more of browsers behavior too.
Please mark this as best answer if it helps
Thanks
Siddharth
OSI Consulting
I know that opening a document in new tab is the standard behavior.What I am looking for is a solution to Force the download, like we can do in VF page by setting the "content-desposition" on page header. Here the issue i am facing is that its not a VF page but a static document, so i cannot set the content desposition.
Veenesh
window.location.assign(url);
If it helps then mark as best answer.
Thanks
Siddharth
OSI Consulting