Generate print preview of a web page in asp.net

前端 未结 3 1047
一个人的身影
一个人的身影 2020-12-22 08:04


This is the only c

3条回答
  •  失恋的感觉
    2020-12-22 08:29

    One way is to use the mediaType print in your css. This css will only be applied when you open you page in print mode. Add following class in your css file:

    @media print {
    // printer friendly page css
    }
    

    Another way is by using pure javascript. there are bunch of articles on internet for this:

    If you are having a common template for printer friendly pages. I would suggest you to create a seperate page altogether for print version and when user clicks on link navigate it to your new printer friendly page. I would recommed this approach as this is foolproof and you have complete control over it, rest of approaches have some pitfalls.

提交回复
热议问题