..:: Blog ::..

 ToolBook Blog Minimize

Jan 12

Written by: Tomas Lund
Monday, January 12, 2009 2:08 PM

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)

 

Tags:

2 comments so far...

Re: Disable browser printing in ToolBook

Thanks,we also used this code for college courses delivered in Blackboard. Unfortunately, as you mentioned the students knew how to circumvent it by using the printscreen key.

By Lisa Plescia on   Monday, January 12, 2009 2:50 PM

Re: Disable browser printing in ToolBook

I got inspired based on your comment and added *some* protection against the user pressing the printscreen button. Like I mention in my note, 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.

By TomasLund on   Tuesday, January 20, 2009 12:40 PM

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel  

  
 Search Minimize


  
 Quick links Minimize


  
 Blog List Minimize


 Print   


Copyright 2007 by ToolBookConsulting.com   Terms Of Use  Privacy Statement