logo

Further Control of Printing

If I had a pound for every time I had started an article with the line "If I had a pound for every time....". Do you see what I've done there?? Sorry, I'm in a daft mood today. Must be all the Christmas food and drink gone to my senses.

Seriously though, there are questions that I get asked so many more times than others that it gets to a point where I have to find out how and then write about it. Even though, in this case, it's not something you would actually find me doing unless I was pressed in to it. In the words of Ruth Harris (the last person to ask me) here's the problem:

The form is several pages long, and when users print out their finished form (in IE5) , it has the lengthy URL at the bottom of each page. Is there any way to make that not print out? It is ugly and looks intrusive on the page.

The answer I usually give depends on the mood I am in. Catch me in a good mood and I'll say "Yes, it can." However, it's the nature of the solution that leads me to sometimes say no. Whether or not you decide to use it is, of course, down to you.

A little background:

Whether or not you see the URL of the current page printed on the page is a part of the Page Setup [File - Page Setup] settings for the user's browser, as shown below.

image


Notice that the Footer box contains the MetaSymbol &u. This tells the browser to print the URL. The others correspond to the following:

Internet Explorer Header and Footer Metasymbols
To print specific information as part of the header or footer, include the following characters as part of the text
Type this To print this
&w   Window title
&u   Page address (URL)
&d   Date in short format (as specified by Regional Settings in Control Panel)
&D   Date in long format (as specified by Regional Settings in Control Panel)
&t   Time in the format specified by Regional Settings in Control Panel
&T   Time in 24-hour format
&p   Current page number
&P   Total number of pages
&&   A single ampersand (&)
&b   The text immediately following these characters as centered.
&b&b   The text immediately following the first "&b" as centered, and the text following the second "&b" as right-justified.


Using the above symbols you can print as little (nothing) or as much information as you like. Note however that these settings apply to all pages once they have been changed.

The solution:

Well, not one but three really. The second is the preferred in my opinion but the third is probably the most interesting and the one I'll spend the most time discussing.

The first and simplest is to tell the user to open the Page Setup dialog and remove the &u meta-symbol. Not very desirable but it works and it can be applied on a basis of only those that object to the URL need to be told how.

Secondly you can administer this via your NT Network using something like IEAK or another central Registry control technique. Either of these would simply control the content of the following Registry key:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup\footer

The third and most complex is to use Mead & Co's ScriptX. This is an ActiveX component that, once downloaded, can allow the developer complete control over the printing process.

When you opened this page (if you are using IE) you probably saw a prompt to accept the install of an ActiveX component. Sorry if this shocked you but I've had to embed this object so that I can demonstrate the technique. If you declined the install initially then you may want to reload the page and accept it. This way you can see what I am talking about. You only need to do this once.

Assuming you have installed the component then you can use the following button to print this page. Notice the difference in the Header and Footer.



Here's another example where you can decide what the Header and Footer should be "on the fly".

Customised Print Settings
Header: Footer:
Prompt: Show settings dialog


So, there you have it. Using JavaScript and the ScriptX component you can cater for occasions where you don't want to see the URL at the bottom of a printed page.

Using ScriptX in Domino:

First thing you need to do is add the ScriptX Cab file as a resource to your site. You can then let users download it, with or without an internet connection. Download it either from the Meadroid site or from the link near the top of this page.

In Domino Designer, go the Image Resource section and choose to add a new one. Navigate to the folder with your ScriptX.cab file in it and type "*.cab" in the File Name box. Select the file and press Open:

image

You can now add the following PassThru HTML code to the form that is going to be printed.

<object classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" id="factory" codebase="ScriptX.cab#Version=5,60,0,375" style="display:none" viewastext>
</object>

You will of course need to alter the codebase attribute so that it points to the correct path of your database. To make this easier I highler recommend you use this method. Next time a user opens this form they will see a prompt to install the component. Most of them will probably just say yes....

Now you just need to add some JavaScript to handle the methods and properties of this new object. How much you add depends on how you want to handle print requests. The most basic would look something like this.

function PrintBasic() {
document.factory.printing.header = "MeadCo\'s ScriptX Changed This";
document.factory.printing.footer = "";
document.factory.printing.Print(true);
}

You can make this even more powerful using the following settings:

document.factory.printing.portrait = false
document.factory.printing.leftMargin = 1.0
document.factory.printing.topMargin = 1.0
document.factory.printing.rightMargin = 1.0
document.factory.printing.bottomMargin = 1.0

These are the just the properties available to unregistered copies of the ScriptX component. License it and you get a whole lot more, extremely useful, functionality.

Summary:

Whether or not you like this method it certainly seems to answer the above problem. How it does it may not be so slick but it shows how powerful ActiveX components can be.

I have only demonstrated the basic features of the ScriptX download. Have a look at their website and see what else it can do for your site. This is also where you will find answers to most problems you may have when implementing the above solution. I have refrained from going in to too much detail as it is all covered in the documentation that comes with the download on the site. They also discuss the necessary settings of the browser for the download to be allowed and provide lots more examples.

Further reading:

http://msdn.microsoft.com/library/default.asp?URL=/library/en-us/dnscrpt/html/dhtmlprint.asp

Feedback

  1. thankyou verymuch

    It is very usefull to us.... thankyou verymuch

  2. Print with background-colors?

    Help,

    I must have (customer pay) an activeX-object that allows me as programmer to change the prints in IE to use: print with background-colors/images? Is it possible with the registred version?

    Best Regards Dave

    1. Re: Print with background-colors?

      Yes, it's possible. If you have a registered version of ScriptX you can specify to print the background colors and images with this line of code.

      printing.printBackground = true

      here's the link to this property: http://www.meadroid.com/scriptx/docs/printdoc.htm#printBackground

      here's a link to the entire reference doc http://www.meadroid.com/scriptx/docs/printdoc.htm#refs

      Show the rest of this thread

  3. Error message not acceptable...

    It was very good stuff..But one problem.. If the user doesnot download the ScriptX.cab object i.e says no when prompted for download...then if he clicks on Print button.. Now an error is thrown saying Object not found(which is obvious).. But he problem is since you cannot control the user atleast it should be made sure that in case he doesnot download the stuff..there is no error shown to him..may be some message may be popped up saying ..." For Printing you need to download the Object"..etc etc.. I tried with my appication biult on ASP.On clients end it's showing JavaScript error if I donot download the object..CHow can I avoid this...???

    I tried to do but it's not working ...in the sense how to know whether the user has downloadd the stuff or not..??? Plz help if possible....

      • avatar
      • James Jennett
      • Tue 9 Apr 2002

      Re: Error message not acceptable...

      S,

      You could try making an early call to

      document.factory.printing.Print(true);

      and if the result of this call is an error or some other rubbish, then you know the user is not running that object, and alert him/her to some url or whatever to d/l it.

      Or make installation of the object part of the standard Notes install for your employer. Where possible.

      Show the rest of this thread

      • avatar
      • Dave
      • Thu 11 Apr 2002

      Re: Error message not acceptable...

      This works in ie atleast!

      <script language="VBscript"> function test on error resume next test = IsObject(CreateObject("ScriptX.Factory.1")) end function </script>

      Call on this function from javascript and it will return true if there is a plugin installet

    1. Try this...(Re: Error message not acceptable...)

      Here is a function that we use that does a check first for the object and if it isn't there then does a normal window.print()

      function printReport() {

      if ( !factory.object ) { window.print(); } else { // set page header and footer factory.printing.header = ""; factory.printing.footer = "&d &b www.bluecuda.com &b Page &p of &P"; // setup printer factory.printing.portrait = false; factory.printing.leftMargin = 0.25; factory.printing.topMargin = 0.25; factory.printing.rightMargin = 0.25; factory.printing.bottomMargin = 0.25;

      //print factory.printing.Preview(); }

      }

      Here's an example call to this function from a button:

      <button onClick='printReport();'><img src="/icons/small-printer.gif"> Print</button>

      Show the rest of this thread

  4. Print more than 1 page

    Jake, I'm wordering if there're a way to print the entire body of the document in frame? My form is a long form, but it's only printed out what it's displayed in a frame. Is there a way to print out the rest of the form?

    Thanks, Kim

  5. Customizing Header

    Hi... I am trying to print a diffenent header on each page of a report which would include a client name. Can this be done??

    For example.. Within a While loop, i want to set a header for each page using JSP like so. factory.printing.header = "<%=clientName%>"; and then print that header to the current page.

    It prints the last client in the list on every page. Is there way to getaround this?

    Any suggestions would be appreciated.

    Thanks Andrea

    • avatar
    • MK
    • Tue 21 Jan 2003

    Multiple Cover Pages

    I have a page which has multiple frames, each frame holds 1 notes document. When I say window.print()and as "print each frame as separate documents" is selected bye default in IE, each document is printed separtely , but along with it a coverpage is alo printed allthe time . is there any way to avoid printing multiple coverpages.?

    Thanks MK

  6. It is very nice

    it helps me alot.

      • avatar
      • Charlotte
      • Fri 12 Dec 2003

      Re: It is very nice

      Great indeed.

      However, I can't get the users to download the plugin.

      Maybe it's some I didn't do.

      <object classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" id="factory" codebase="<Computed Value>ScriptX.cab#Version=5,60,0,375" style="display:none" viewastext> </object>

      Whereby I put in the Computed Text:

      DBPath + "/$File/"

      Did I miss out anything?

      Show the rest of this thread

    • avatar
    • Dhanji
    • Thu 18 Dec 2003

    Cannot Install ?

    hi j

    ur solution impressed me. My User PL doesn't want the Header, Page of Page and the footer URLs while pringting.

    at our side the pc are controlled whereby users cannot install any of the plugins/softwares, b'coz they dont have administrator access.

    How to handle such a situation?

    cheers dhanji

    1. Re: Cannot Install - My Email ID

      i missed out the email id in the earlier thread.

    • avatar
    • Greg
    • Thu 12 Feb 2004

    ScriptX download

    This is what I have for my HTML Object Code:

    object classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" id="factory" codebase="onr/webtec01.nsf/ScriptX.cab" style="display:none" viewastext

    But users are not getting prompt to download the file. Is there anything else that I need to do?

      • avatar
      • Greg
      • Thu 12 Feb 2004

      Re: ScriptX download

      I think I found my problem but I will not be able to test it until I go to the client site.

      My problem was that I forgot a "/" at the beginning of my codebase url.

      Show the rest of this thread

    1. Re: ScriptX download

      thank you

  7. Its Nice

    It is Really Excellent Article.

    I really looking for web base printing solution and you explained so well. I realy impressed.

  8. Hide Header & Footer

    Hi,

    using Java script i want to print a page but dont want Header/footer will get print.

    I read above ScriptX. My question is if i will use FREE Version then is it possible that i can give Codebase address of my local server instead of Mead download url. As there are few clients which dont access Internet from their PC.

    Regards, Pradeep Chauhan

    1. Re: Hide Header & Footer

      Hi,

      using Java script i want to print a page but dont want Header/footer will get print.

      its is very usefull for me

      Regards, Amarpreet S. Rajwans

  9. Its very nice..

    Hi, It is very nice quoting ..Its help me lot..

    Thanks,

    Sreejith P S

    • avatar
    • BlueAngelZion
    • Thu 26 Aug 2010

    The best code ever!!

    I am really impressed.

    This code works great. Just be careful with the path that you put on codebase"" this is very important to make the window popup to install the ActiveX-Object.

    Thanks

    • avatar
    • Venkat
    • Sat 1 Oct 2011

    Hello All,

    I am trying to print one sample screen form in flex using scriptX . i have downloaded the cap file and installed meadco's scriptX in my system. but am not able to proceed further since i dono how to use that object

    ("object classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" id="factory" codebase="onr/webtec01.nsf/ScriptX.cab" style="display:none" viewastext ") in my flex file.also i dont know where i need to place my smsx.cap file. i am trying to print it from client end itself.

    if any of you know the solution means kindly help me to fix this asap. its little urgent

Your Comments

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



Navigate other articles in the category "Forms"

« Previous Article Next Article »
Improving Form Performance   What you need and want to know about errors

About This Article

Author: Jake Howlett
Category: Forms
Keywords: ActiveX; Print; Header; Footer;

Attachments

ScriptX.cab (136 Kbytes)

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 »