Wrox Programmer Forums
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 11th, 2005, 06:41 PM
Authorized User
 
Join Date: Jun 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default PRINT function

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!

 
Old July 12th, 2005, 01:37 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old July 20th, 2005, 08:35 AM
Authorized User
 
Join Date: Jul 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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/de...intpreview.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
 
Old July 21st, 2005, 02:09 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

But how do you use them in a web page?

--

Joe (Microsoft MVP - XML)
 
Old July 21st, 2005, 08:09 AM
Authorized User
 
Join Date: Jul 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.


<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> <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.c...opic&topicID=6.

Good luck and let me know how it work out for you.

Grace :)
 
Old July 21st, 2005, 08:13 AM
Authorized User
 
Join Date: Jul 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 :
 
Old July 21st, 2005, 09:08 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old April 30th, 2006, 11:21 AM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old September 12th, 2006, 04:12 PM
Registered User
 
Join Date: Sep 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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



 
Old September 20th, 2006, 03:12 AM
Registered User
 
Join Date: Mar 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript print function mii2029 ASP.NET 3.5 Basics 2 September 27th, 2008 12:56 PM
Textbox problem print preview vs. print jenisageek Access 5 May 2nd, 2008 12:54 PM
How to use Print Hidden Function kiwibey Javascript 6 May 12th, 2005 11:38 AM
print the hidden page without the print dialog box kayzem Classic ASP Basics 0 April 21st, 2005 11:31 PM
Print and print preview file on the website withou appleLover General .NET 0 February 19th, 2005 02:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.