Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Hide Text from printing

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#Hide_Text_From_Printer or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/Hide_Text_From_Printer


I had a requirement to print selected documents from the web browser. A side request was to display instructions which would not print.





Here's how to do it.

In Notes, it is easy, you deselect the hide formula: "Hide paragraph when document is printed" .

 

On the web it is a bit trickier, here is how I do it:

I create a style sheet class that hides from mediatype print. This must then be used as the class for <br> <p> etc tags.

In the Lotus Notes Domino Lotus Script agent use:

 Call rt.AddNewline(1)
Call rt.appendtext("<style type='text/css'>]")
Call rt.AddNewline(1)
Call rt.AppendText("[<!--  ")
Call rt.AddNewline(1)
Call rt.AppendText("@media print{")
Call rt.AddNewline(1)
Call rt.AppendText(" .printHidden{ ")
Call rt.AddNewline(1)
Call rt.AppendText("  display:none; ")
Call rt.AddNewline(1)
Call rt.AppendText(" } ")
Call rt.AddNewline(1)
Call rt.AppendText(" }")
Call rt.AddNewline(1)
Call rt.AppendText("-->]")
Call rt.AddNewline(1)
Call rt.AppendText("[</style>]")
Call rt.AddNewline(1)

This outputs the code:

<style type='text/css'>
<!--  
@media print{
.printHidden{
display:none;
}
}
-->
</style>

Then the actual lotusscript code that is not to be printed can be displayed using the agent:

 Call rt.AddNewline(1)
Call rt.AppendText("[<h2 class='printHidden'>Instructions:</h2>" )
Call rt.AddNewline(1)
Call rt.AppendText("<p class='printHidden'>" )
Call rt.AddNewline(1)

Call rt.AppendText("You can " & _
"<a class='printHidden' href='#' onClick=' window.print();' >print</a>" & _
" these pages, there are page breaks in between each document. NB: The ----- Titles ----- will not be printed." )
Call rt.AddNewline(1)

Call rt.AppendText("</p><br class='printHidden'>]")

which creates html:

<br>
<h2 class='printHidden'>Instructions:</h2>
<p class='printHidden'>
You can <a class='printHidden' href='#' onClick=' window.print();' >print</a> these pages, there are page breaks in between each document. NB: The ----- Titles ----- will not be printed.
</p><br class='printHidden'><p class='printHidden'>---------01. Product Decisions in MSG---------</p>

NB This code also includes a link to actually print the page.

Finding HTML or javascript code that would do a print preview was trickier.

I found some but it was not reliable: HTML version: http://forums.aspfree.com/html-help-7/help-with-print-preview-30747.html

If you have some let me know.

 

 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
man and boy by Tony Parsons
British book of the year 2000. Great book, hard to put down, but I nearly threw it away half way through. You'll know why when you read it.
See at: Amazon.co.uk | Amazon.com |