logo

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 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:
  1. Make a copy of the form
  2. Rename it to "PrintForm"
  3. Simplify its design and layout to make it suitable for printing

The View:
  1. Create a view called "PrintView"
  2. Make sure it selects documents using the "OrigForm" form
  3. Give it a Form Formula of "PrintForm"

    Image


The Link:
  1. In the "FormOrig" form add some Computed-Text
  2. 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.

Image


Feedback

  1. Another suggestion

    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.....

    Jake -CodeStore

    1. 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.....

  2. Printer Friendly page

    Just wanted to thank you for your help on this subject. Your discussion and descriptions made the process very simple.

  3. 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.

    db.nsf/wPrinterVersion?openform&ParentUnid=@Text(@DocumentUniqueID)

    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.

    Jason

      • avatar
      • e
      • Thu 10 Mar 2005

      Re: Another Printer Friendly Method

      Estupendo,

      Gracias Jake

  4. Hello,

    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?

    Thanks!

      • avatar
      • Jake Howlett
      • Tue 22 Jun 2010

      If the document has yet to be submitted to the server then this approach won't work. You'd be better off using a JavaScript/DHTML approach and "document.write()" everything to a new window with some print CSS in it.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:



Navigate other articles in the category "Forms"

« Previous Article Next Article »
Control how attachments are removed   Communicating with a pop-up's parent

About This Article

Author: Jake Howlett
Category: Forms
Keywords: print; view; form;

Options

Feedback
Print Friendly

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »