简体   繁体   中英

Rendering salesforce lightning component into pdf (Generate PDF)

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 !

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();

打印选项图像

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM