0

Can someone help me to download a VF page when the user clicks on the download button? Current functionality is when the user clicks on the download button it will take the user to Print page and user needs to save the document as pdf on the selected folder. I would like to update that to download directly when the user clicks on the download button. Thank you

The print code is as below

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        document.title = '{!Name} - Report';
        window.print();
    });
</script>

closed as off-topic by Sebastian Kessel, Pranay Jaiswal, glls, Vijay Ganji, battery.cord Jul 22 at 13:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Sebastian Kessel, Pranay Jaiswal, glls, Vijay Ganji, battery.cord
If this question can be reworded to fit the rules in the help center, please edit the question.

1

Check out the best answer on this Salesforce developer post: Visualforce page download as a PDF when Button click

The post is about a similar use case and the answer is well described with some sample code

  • Thank you for your help. It worked but I had to add a different method for the code provided. – Abby Jul 23 at 23:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.