|
Subject:
|
PRINT function
|
|
Posted By:
|
kuku
|
Post Date:
|
7/11/2005 6:41:21 PM
|
Hi everyone,
I would like to print a page from front page but how i can eliminate the address and the date print at the bottom of the page? Any code to eliminate that? or i just need to modify the HTML code in front page? Please help! Thanks!
|
|
Reply By:
|
joefawcett
|
Reply Date:
|
7/12/2005 1:37:22 AM
|
If you are talking about programmatically removing the header and footer added in by the browser you can't unless using IE and the site is in the "Trusted sites" or the "Local intranet" zone. You can then use a print template to control print preview, margins and page settings, not sure if there is an equivalent process in non IE browsers.
As a user go into File|Page Setup using IE, I think it's something similar in Mozilla too.
--
Joe (Microsoft MVP - XML)
|
|
Reply By:
|
gracehanh
|
Reply Date:
|
7/20/2005 8:35:08 AM
|
Hello kuku,
In addition to joefawcett, here is your solution but you have to have Javascript in your code though.
Just go to this site and copy and paste all the functions and the example is really easy to follow. http://www.webreference.com/js/column94/7.html If you want more understanding of what the Print Template does, go to this website also. It describes it in detail and by using the site above u'll understand more. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnie55/html/beyondprintpreview.asp
I am trying to use the same Print Template for my xslt but it doesn't recognize the <HTML XMLNS:IE> namespace. If you know or get it working, let me know.
Good luck!
Grace
|
|
Reply By:
|
joefawcett
|
Reply Date:
|
7/21/2005 2:09:53 AM
|
But how do you use them in a web page?
--
Joe (Microsoft MVP - XML)
|
|
Reply By:
|
gracehanh
|
Reply Date:
|
7/21/2005 8:09:25 AM
|
Hi Joe and kuku,
Forget about the solution that I suggested before, I have a better solution. I found this site (http://www.meadroid.com/scriptx/freedep.asp) and they have this amazing ActiveX print controller. Go to the website and read on. But here is the snippet of code that I am using in my xslt file.
<style type="text/css" media="print,screen" > .noprint { display: none } </style>
<script language="javascript"><![CDATA[ function window.onload() { factory.printing.header = "&bMeridian Cast Production Report&b" factory.printing.footer = "&bGenerated: &d &t &bPages &p of &P" factory.printing.portrait = true; //THIS LINE IS ONLY USED WHEN A PRINT BUTTON IS ADDED ONTO THE REPORT PAGE //idPrint.disabled = false; // enable UI button }
function Print() { factory.printing.Print(false); // no prompt } ]]> </script> In your body tag, place this in.
<!-- MeadCo ScriptX --> <object id="factory" viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="ScriptX.cab#Version=6,2,433,14"> </object>
Note that in my code I removed the viewastext b/c it doesn't recognize it. Also, since you mentioned you are using Front Page then you must remove it the "viewastext". If you go to the website above, you will know what I mean. I actually just use the example that they provided on the website and implemented. Nice and clean.
Here is another option that another person (his name is "evagoras") suggested to me:
<html><head> <!-- MeadCo ScriptX --><object id=factory style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=6,2,433,14"></object> <script language="javascript"> function printWindow() { // get page properties var page_header = factory.printing.header; var page_footer = factory.printing.footer; // change page properties factory.printing.header = "This is my custom header"; factory.printing.footer = "And this is my custom footer"; factory.printing.portrait = true; factory.printing.leftMargin = 1.0; factory.printing.topMargin = 1.0; factory.printing.rightMargin = 1.0; factory.printing.bottomMargin = 1.0; factory.printing.Print(true); // reset page properties factory.printing.header = page_header; factory.printing.footer = page_footer;} </script> </head><body>Â Â <button onclick="printWindow()">Print this page!</button></body></html>
and to understand more you can go to this site. I originally posted my question here. To view the topic go to http://209.200.89.134/forums/index.cfm?page=topic&topicID=6.
Good luck and let me know how it work out for you.
Grace :)
|
|
Reply By:
|
gracehanh
|
Reply Date:
|
7/21/2005 8:13:57 AM
|
Hi Kuku and Joe, I forgot to answer kuku's original question.
If you don't want to the address and the date print at the bottom of the page then in the factory.printing.header = "&bMeridian Cast Production Report&b" factory.printing.footer = "&bGenerated: &d &t &bPages &p of &P"
Replace those with whatever you want.
Grace :
|
|
Reply By:
|
joefawcett
|
Reply Date:
|
7/21/2005 9:08:16 AM
|
Yes, ScriptX is an excellent product, even better than the print stuff is the factory.wait method which allows page updates during long running events. However it has two main drawbacks, the user must allow ActiveX installs and even then some of the print features only work if the site is in the "Trusted sites" or "Local intranet" security zones. There are other ActiveX controls that allow PrintTemplates to be used from within a browser but again they only work on ActiveX enabled IE browsers.
--
Joe (Microsoft MVP - XML)
|
|
Reply By:
|
trugge
|
Reply Date:
|
4/30/2006 11:21:40 AM
|
When trying to use the latter of the two script examples I get the folowing error: Microsoft JScript runtime error: 'factory.printing.header' is null or not an object
In this code line: var page_header = factory.printing.header;
Help is wanted, please
Torben
Thanks Torben
|
|
Reply By:
|
saravanan thirumalai
|
Reply Date:
|
9/12/2006 4:12:12 PM
|
Microsoft JScript runtime error: 'factory.printing.header' is null or not an object
This is because the ActiveX is not installed in your machine. I was using the smsx.cab for printing and got the same error. This was solved once I installed smsx.exe in my machine.
~ Saran
|
|
Reply By:
|
decyclone
|
Reply Date:
|
9/20/2006 3:12:42 AM
|
Hey, it might be off the topic, but ever tried file -> page setup dialog, both ie and firefox provide that. that dialog has options to change or eliminate header and footer. I hope it helps. by the way nice ActiveX control.
|
|
Reply By:
|
swati.smc
|
Reply Date:
|
10/9/2006 7:02:35 AM
|
Hi, any ideas what to do, in case there is no Print button. It is a Certificate that I am making. The page has np 'Print' button on it and the user needs to print it from the Print option given in the Toolbar. The certificate opens up in a new window when a 'Print' link is clicked on the parent jsp.
|