I have created a VF page with renderas=PDF and added it as a quick action on the Account object in Lightning Experience. When I click the quick action, a PDF view displays and is correct. How can I add a button or icon to Download that PDF and also a button or icon to Print that PDF?


Print & download option comes from the browser's pdf viewer.

If you still want to have a button somewhere in your org to download the page, have the button, onclick of which redirect the user to the VF page and when the page load, have the following line in the constructor of the controller

Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=YourFileName.pdf'); 

It should save a PDF in your local drive.

You can have a salesforce button for print as well.

window.print() is the function you need to call from the button, it will send the current page for print.

Please note: you can not have this Javascript in a VF page which is rendered as PDF, JS doesn't run when the page is rendered as PDF.


If this question is still open, we can follow below steps to implement the download in lightning experience

  1. You should have a visualforce page for generating pdf.
  2. In lightning component use following markup

    <!--lightning button to download the pdf as generated reports -->
        <div class="slds-float--right">
        <button class="slds-button" onclick="{!c.download}">
        <lightning:icon class="slds-icon slds-input__icon slds-input__icon_right slds-icon-text-default" iconName="utility:download" size="small" alternativeText="Indicates approval"/>
  3. Lightning controller should have following markup

    //Download Reports as Pdf File  
    download : function (component,event,helper) {  
  4. Lightning helper should have following markup

    // Generating Pdf  through VisualForce Page
    downloadPdfFile : function(component,event,helper){
        var selectedwarehouse = component.get("v.selectedProduct"); //pass this value into vf page
        var fromDate = component.find("fromDate").get("v.value"); /pass this value into vf page
        var toDate = component.find("toDate").get("v.value");  /pass this value into vf page
          $A.getCallback(function() {
            // visualforce page URL
         }), 1000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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