Reputation: 1391
I think it's not possible, but I want to make sure.
Upvotes: 7
Views: 1181
Reputation: 56430
One possible way would be to have a print CSS (<link rel="stylesheet" href="..." media="print" />
), but have a server-side script pre-process it. Basically just a simple rewrite rule to rewrite the print.css, or whatever file you use, to be proxied to a script that will log the request to some database, and then finally output the actual CSS.
Of course this isn't a perfect method; if someone uses a print preview it'll also be processed by the script.
Upvotes: 9
Reputation: 115498
It's not possible. Even if you could have an auto post back event which fired when someone tried to print, there is nothing stopping them from saving the HTML page to disk and printing it at a later date.
Upvotes: 0
Reputation: 15069
You can't.
And even if you could, Someone can even take a Screenshot of the page, Printscreen ect...
if you want to secure a content there are other ways to do it (non are totally immune)
Upvotes: 0
Reputation: 4573
You can never positively confirm what clients do with the output from your service.
Upvotes: 0
Reputation: 13691
This would happen clientside so this is impossible. The only thing you can try is to make an easy button to print the page and simply hang a counter on that, hoping that everyone uses that button instead of the File -> Print option in the browser.
Upvotes: 4
Reputation: 630469
You cannot, nothing is sent to the server when this happens, and no events are fired.
IE has onbeforeprint
and onafterprint
events you could use, but they are IE specific, so not counting them as a solution.
Upvotes: 5