Disable browser printing in ToolBook
UPDATE 20 January 2009: Updated the sample and download to include some protection against the user pressing Printscreen.
This sample demonstrates how one can prevent users from printing elearning content created with ToolBook .
Updated samples are here: Live version or download the source from the Download page (file is called DisablePrint2(9)).
See the old version of the live version of the sample or download the source from the Download page (file is called DisablePrint(9)). Note to access the downloads page you need to create a free account on this site.
Here is how it works
On the background of this page there is an on load background action which calls a JavaScript function which is responsible for dynamically loading a css file.
The contents of the css file is a clever way to prevent printing:
@media print {
body {
display:none
}
}
Here is how to read it: The style sheet will only be in effect when the document is printed (eg @media print)
There is only one css selector (body) which basically means the html document for our purposes has its display property set to none (display:none) which will make it invisible.
To clarify: While the print dialog is still enabled, the result is that a blank page is printed. Note I didn’t invent this CSS trick, I merely integrated it into ToolBook. To test this try printing this page by pressing CTRL+P (if you know how to, please print to a pdf or similar file to save some trees:-))
Note 1. Despite the added security of the printscreen prevention measures in this sample in this updated sample- This is NOT a 100% certain approach - nothing is 100% certain (except taxes and death). However in case this level of security is sufficient for some, I will refrain from providing "inspiration" to those trying to bypass the protection by going in more detail on how one might do that.
Note 2. This builds on a previous blog post I did on using an external css style sheet to change the visual appearance of ToolBook content when published to HTML.
Note 3. The css file is included in a hidden file placeholder on the last page of this book. The page has skipnavigation set to true to prevent it from being displayed. This automatically ensures that the file is copied to the media directory when the file is published to html. (For some reason my trick described in "Adding files to HTML media directory" doesn’t work with css files)