0

I am working on a lightning component and within the components layout I have to provide a button which can generate pdf of that lightning component . I found some blogs but still not sure about the actual solution for this . Please let me know if you guys have some sample implementation example for doing this . Thanks !

Akum
  • 63
  • 1
  • 2
  • 12
  • There is no direct tag in lightning that will render the page as PDF. Why dont you use a VF page instead to render your page as PDF and call it from your lightning component. – Rockstar May 15 '18 at 13:24
  • I had almost same requirement as you,I could not find solution so what I did I created VF page render as pdf, onclick lightning us pass in the id to the url of the VF and it should get a pdf – Amer Bearat Aug 17 '18 at 08:13

1 Answers1

0

If you want to save the entire window, you can just open the print window then save as PDF (if the business requirement allows):

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

If you want to print a portion of your lightning component, you might need to reconstruct the page to the pdf. Follow this:

var myWindow = window.open('','_blank', 'width=' + screen.availWidth + ',height=' + screen.avaliHeight);
myWindow.document.write('<html>HTML CODE HERE</html>');
myWindow.document.close();
myWindow.focus();
myWindow.print();

Print Option Image