I have a use case in which a user can view an invoice on the screen. I want to add a button to print the invoice, either printing to paper or pdf.
The printed version should fit the a4 and should only have the invoice. So navbar and print button should be excluded from the printed version.
I noticed I could use window.print(), but I did not succeed to apply a specific css. I als tried to set a state prior to the print event, but that didn’t work.
Looking forward to see some tips and tricks for this.
You can control how things print through a CSS media query applied through custom CSS. But there’s an interesting alternative approach in the form of paper CSS that you could include in either custom code or using the State Change weweb embed tool:
Hey there, I’m trying to set up paper css to print certain elements from a page. Following this guide, it seems that it’s required to add a class tag to the body element. Was anybody able to do this? (When I try to add custom code in the body element, I basically only add the code inside the body element, I’m not able to add the class to the body element itself.)