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
Ashirbad PattanayakAshirbad Pattanayak 

print a lwc component

Hi,

Can someone please help on how we can add a print button on a lwc component page for Print. And on clicking on this the entire component will be open in a new window for print. Could not find a suitable solution till now. Winodw.print will print the entire wndow. But i want to print only the specific component html. There might be multiple components in the page.

Thanks,
Ashirbad
Best Answer chosen by Ashirbad Pattanayak
NitishNitish
Hi Ashirbad,

Accoring to me the only option we have is to put slds-no-print in all the components which you dont want to use when you are printing. 
We cant use innerHtml so i dont think as of now its possible.

Thanks,
Nitish Singh

All Answers

NitishNitish
Hi Ashirbad,

Accoring to me the only option we have is to put slds-no-print in all the components which you dont want to use when you are printing. 
We cant use innerHtml so i dont think as of now its possible.

Thanks,
Nitish Singh
This was selected as the best answer
Ashirbad PattanayakAshirbad Pattanayak
Thanks Nitish. This really helped. 
We can use a window.print to print the whole page. And can have slds-no-print css class added to the sections which need not come in the print.
 
Rohith V 4Rohith V 4
Hi Ashirbad, i am working on a similar functionality. Can we connect? I am new to LWC so id really appriciate it if you can spare some time.