+ Start a Discussion
Raghavendra M 13Raghavendra M 13 

How to save PDF attachment using Lightning Component?

When clicking on a lightning button displaying a visual force pdf page , how can i insert that pdf attachment in notes and attachments
Pradeep SinghPradeep Singh
Hi,
please refer 
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/aura_compref_lightning_fileUpload.htm

If this solves your problem, mark it as solved.
Raghavendra M 13Raghavendra M 13
The following is my scenario:
When clicking on a lightning button displaying a visual force pdf page , how can i insert that pdf attachment in notes and attachments
 
Pradeep SinghPradeep Singh

You can use 2 VF pages for that.One page contains button to save PDF as attachments and contains 2nd page(rendered as PDF) in iFrame.
When clicking on save button run a controller method to save the PDF as attachment. 

Use something like this your method. 

currentid = Apexpages.currentPage().getParameters().get('Id');
PageReference pageRef = new PageReference('/apex/newinvoice?id='+currentid);
pageRef.setRedirect(true);
Blob pdfBlob = pageRef.getContentAsPDF();  
Attachment att = new Attachment();                    
att.Name = 'Pradeep'+'_'+ string.valueOf(System.today())+'.pdf'; 
att.ParentId = currentid;
att.Body = pdfBlob;