Creating a printer friendly page
It appears that nowadays most info-centric web-sites seem to have a "Printer friendly" version of each page. Examples include Wired.com and vnunet.com. That is why I decided not long back that CodeStore.net should have its own version so as not to be out-done. Oh, and becuase it's useful too, of course. You can see the result by using the link on the right in the red table or with
Ed's Notes: Since I wrote this article I have implemented a new design and chose to use CSS to control the appearance of printed articles rather than this method. However, this is still worth a read if you can't assume all visitor's browsers will support this method.
When I did this I wasn't expecting to be asked how I had done it, mainly because, as you'll see if you read all of this, it is quite a simple technique.
Form Formula. We've all heard of them, most of us know what they do but how many of us actually use them?? For those that don't know what a Form Formula is, it is a view property that will let you specify what form to use when a document is opened from a particular view. So all we need to do is create a view that uses a special print version of a form. Let's say that your database has a set of documents that use a form called "FormOrig". This is how you would go about printing them:
- Make a copy of the form
- Rename it to "PrintForm"
- Simplify its design and layout to make it suitable for printing
- Create a view called "PrintView"
- Make sure it selects documents using the "OrigForm" form
- Give it a Form Formula of "PrintForm"
- In the "FormOrig" form add some Computed-Text
- Give it the formula - "<a href=\"../PrintView/" + @Text(@DocumentUniqueID) + "?OpenDocument\">Print Version</a>"
When the link is used, domino knows that it needs to open the document using the form called "PrintForm" which gives the user a customised, printable layout. Et voila...
A few suggestions:
Some sites like to open the print version in a new window. To do this simply add "target=_blank" to the link. Personally I like to think that my users have the intelligence to use the back button. You do don't you!?
if ( confirm( 'I can print the page now if you want?' ) ) window.print();
Only put this line in the onload event for Internet Explorer. It doesn't work in Netscape (what does!?).
Note: In version 4 of Notes you will find the Form Formula setting in the advanced tab of the view properties dialogue box.
Something I learnt the other day - If you put the following line in to the <head> tag of a page in IE4+ then choosing print from the file menu will automatically use the "Print" form from the "print" view. [<span class="html">] <link rel="alternate" media="print" href="../prnt/DocID"> [</span>] This of course assumes the user [<i>always</i>] wants to use that form.....
problem with frames
I am using the 'link rel = ' to automatically print the selected document on an alternate form. This works perfectly until I put my doc in a frame of a frameset and then it seems to ignore the link completely.
Do you know how I can get round this at all? And please dont tell me to remove all the frames! I know you dont like them.....
Printer Friendly page
Just wanted to thank you for your help on this subject. Your discussion and descriptions made the process very simple.
Another Printer Friendly Method
Here is another method for printing pages. Build a printer friedly Response form (wPrinterVersion), enable the "Formulas inherit values from selected document" and then get the desired fields. On your documents you will have a link with a bit of computed text as follows.
This is an EASY way of doing this, I haven't had any problems but if anybody knows why this method shouldn't be used let us know.
Re: Another Printer Friendly Method
I am working with a web form and trying to use your example on my project. I'm a bit confused on the instructions. I am assuming you have to save the web form first then open it with the instructions you gave? I'm trying to click a hotspot link and open a print-friendly form before the form is submitted. I'm not sure what I'm missing here. Can someone assist me please?