1

I have a lightning component (called from a quick action), on which a few inputs are taken. On clicking of a button I need to show a Visualforce PDF page. Can I do so directly from the button or do I need to go via the component controller etc...?

So here's the button on my component, which is currently set to go to the controller. But what then?

<lightning:button label="Generate PDF" aura:id="generatePDF" onclick="{!c.generatePDF}" class="slds-button--brand"/>

This is my lightning component controller's function, which points to the helper now, but I don't know how to show the pdf, or how to pass the parameters from the component (a date and an id).

generatePDF: function(component, event, helper) {
    helper.generatePDF(component);                                                   
}, 

And this is what I have in my helper:

generatePDF:function(component, event, helper){
    var action = component.get("c.generatePDF");
    action.setParams({
        "recid": component.get("v.rootController.recid"),
        "seldate": component.get("v.rootController.seldate"),                
    }); 

    // Set the Callback
    action.setCallback(this, function(response) {
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
        }
    });
    $A.enqueueAction(action);        
} ,  

And in my apex controller, which is probably nowhere near correct. Help please!

    @AuraEnabled
public static void generatePDF(id recid, string selquarter){
    myPDF(recid, selquarter);
}
public static PageReference myPDF(id recid, string enddate){

    PageReference inPage = new PageReference('/apex/MyNewPDF');
    inPage .getParameters().put('recid', recid);
    inPage .getParameters().put('enddate', enddate);
    inPage .setRedirect(true);
    return inPage ;        
}

Your Answer

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

Browse other questions tagged or ask your own question.