function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kartik BhallaKartik Bhalla 

How to generate pdf from aura component ?

I need to generate pdf from a button in my aura component and also want the data in table format in pdf. plz help me. I have searchd alot on google & got one solution but facing error in that solution also. please help me..
PriyaPriya (Salesforce Developers) 

Hi Anusha,

You cannt generated PDF by using lightning component direcly ..  use need to use the visualforce page and call its from the lightning exp ..


There are two methods to show a PDF in Lightning Component.
First, you can create a Visualforce page and embed it in the Lightning component. 
Second is, usage of PDF.JS library to directly use lightning component to display the PDF.

refer this links

https://medium.com/@ToAnshulVerma/salesforce-lightning-generate-pdf-from-lightning-components-with-in-memory-data-cd5dffe0fe25
https://salesforce.stackexchange.com/questions/205065/how-to-generate-view-pdf-using-lightning-components/205227
http://www.vermanshul.com/2017/07/lightning-generate-pdf-from-lightning.html

Regards,

Priya Ranjan

Anonymous DeveloperAnonymous Developer

There are two methods to show a PDF in Lightning Component.

 


First, you can create a Visualforce page and embed it in the Lightning component.

See detailed example here: https://www.vermanshul.com/2017/07/lightning-generate-pdf-from-lightning.html

 

Second is, usage of PDF.JS library to directly use lightning component to display the PDF.

See details here: 

https://medium.com/my-journey-with-salesforce1-platform/pdf-viewer-lightning-component-f96e6a5704ab

 

 

Entire source code can be found here: https://github.com/kumarrk21/PDFViewer

Let me know if this helps!

Anonymous