I’m just curious how most people make their ASP.NET pages printer-friendly? Do you create a separate printer-friendly version of the ASPX page, use CSS or something else? How do you handle situations like page breaks and wide tables?
Is there one elegant solution that works for the majority of the cases?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You basically make another CSS file that hide things or gives simpler “printer-friendly” style to things then add that with a media="print" so that it only applies to print media (when it is printed)
<link rel="stylesheet" type="text/css" media="print" href="print.css" rel="nofollow noreferrer noopener" rel="nofollow noreferrer noopener" />
Method 2
Our gracious host wrote a good blog post on this topic:
Coding Horror: Stylesheets for Print and Handheld
Method 3
I am a php user, but the point must be that the result no matter what is HTML and HTML is styled with CSS and there is an option for your style sheets for just using the style for printing. This should be the way to do it, imho. About big tables, there isnt really a magic “fix” for that. Page will break where it breaks, dont really understand the problem here either.
<link rel="stylesheet" type="text/css" media="print" href="print.css" rel="nofollow noreferrer noopener" rel="nofollow noreferrer noopener" /> <link rel="stylesheet" type="text/css" media="screen" href="screen.css" rel="nofollow noreferrer noopener" />
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0