You need to sign in to do that
Don't have an account?
Pasan Eeriyagama
How to print a div content in a Lightning component?
I'm trying to print content inside a div as below.
But this did not work. Anyone got a working example to print within Lightning components please. Appreciate any help. Thanks.
printPreview: function(component, event, helper) { //window.print(); var divToPrint=component.find("printableDiv"); console.log('divToPrint.outerHTML: '+JSON.stringify(divToPrint.innerHTML)); newWin= window.open(""); newWin.document.write(divToPrint.outerHTML); newWin.print(); newWin.close(); },
But this did not work. Anyone got a working example to print within Lightning components please. Appreciate any help. Thanks.
var pt = pc.getElement().innerHTML;
var newWin= window.open("");
newWin.document.write(pt);
newWin.print();
newWin.close();
That throws same error "newWin.document is undefined" .
This is not solved at the time I'm writing this reply, there is this idea (https://success.salesforce.com/ideaView?id=0873A000000TsNQQA0)for Salesforce.
Just a note:
I asked them to merge that idea with this one, but vote for both until the get'r done.
https://success.salesforce.com/ideaView?id=0873A000000CTHKQA4