How to generate/view PDF using Lightning Components?

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

  • Second is, usage of PDF.JS library to directly use lightning component to display the PDF. See details here .Entire source code can be found here.

Let me know if this helps!


You can embed a vfPage (renderas="pdf") in lightning component and utilize the component in required place.

<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global" >
<iframe src="{! '/apex/pdfPage'}" width="100%" height="500px;" frameBorder="0"/>

Hope it helps!