To customize the way CSS rules are applied during printing, consider using CSS media queries. This approach allows you to target specific elements and determine how they should be displayed when a web page is printed. For more information on this technique, check out the following answer: How do I hide an element when printing a web page?.
One strategy is to assign different classes to key elements before printing, which can help control the styling and layout of the printed document.
Alternatively, you can create a separate stylesheet with a media type set to "print". This will ensure that the styles in this sheet are only applied when the page is being printed.
In certain scenarios, you may opt to open a new window containing the content to be printed and then print that window directly. However, it's generally recommended to avoid opening unnecessary windows unless absolutely necessary.