Creating a printer friendly page
Jake Howlett, 12 Febraury 2001
Category: Forms; Keywords: print
view
form
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 this link.
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:
The Form:
- Make a copy of the form
- Rename it to "PrintForm"
- Simplify its design and layout to make it suitable for printing
The View:
- Create a view called "PrintView"
- Make sure it selects documents using the "OrigForm" form
- Give it a Form Formula of "PrintForm"
The Link:
- In the "FormOrig" form add some Computed-Text
- Give it the formula - "<a href=\"../PrintView/" + @Text(@DocumentUniqueID) + "?OpenDocument\">Print Version</a>"
This will produce a link that looks something like this:
...ef="/dir/db.nsf/PrintView/D4197366....
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!?
In my version I have IE ask the user if they want to print the page straight away. To do this I simply place the following line of JavaScript in the onLoad event:
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.
Copyright © 2000 - 2024 Jake Howlett of Rockall Design ltd. This article was printed from codestore.net