Google Answers Logo
View Question
 
Q: Printing background in Internet Explorer (scripted) ( No Answer,   5 Comments )
Question  
Subject: Printing background in Internet Explorer (scripted)
Category: Computers > Programming
Asked by: fluxsmith-ga
List Price: $200.00
Posted: 03 Nov 2005 15:27 PST
Expires: 03 Dec 2005 15:27 PST
Question ID: 588628
Internet Explorer has an option (normally off) for printing background
colors.  I need a webpage on my intranet to be able to turn this
option on when it is loaded, so that regardless of the users normal
setting, this page prints with the background color(s).  I'm looking
for some Java script to accomplish this.
I know it can be done because MeadCo's ScriptX product can do it in
the licensed version (for me this functionality is not worth
purchasing an annually licensed product).

Request for Question Clarification by leapinglizard-ga on 04 Nov 2005 00:20 PST
In the JavaScript object model, the browser object does not include a
representation of the background printing option, so there is no way
to accomplish what you desire with JavaScript.

However, it is possible to modify Internet Explorer settings by
changing the associated registry key with an ActiveX control. Do you
want someone to write such an ActiveX control for you, or do you just
need to know the path of the registry key that needs to be changed?

leapinglizard

Clarification of Question by fluxsmith-ga on 04 Nov 2005 07:59 PST
I need something ready to integrate into the web page. Since that
solution makes a global change there would at least need to be a way
to make it brief.  I.e. set the registry key when the user actually
chooses print or print preview and restore its original value as soon
as the page has been rendered.
I'd be looking for the ActiveX control and whatever html snippets are
required to integrate it in that manner.  The control could be written
by the answerer, or something commercially available for a reasonable
one-time charge.
Although the ScriptX control only requires you to set a property in
the windows onload routine, I would expect it *not* to make a global
settings change at that time!
Answer  
There is no answer at this time.

Comments  
Subject: Re: Printing background in Internet Explorer (scripted)
From: georgelawrence-ga on 04 Nov 2005 10:23 PST
 
I've got an approach that will probably work for you.  But I can't
figure out how to sign up so I can "Answer" your question.  Hmmm...

Anyway, can you mock-up one of your pages and post the URL?  I'll add
my background color printing tequnique to the HTML and you can have a
look.
Subject: Re: Printing background in Internet Explorer (scripted)
From: fluxsmith-ga on 04 Nov 2005 11:20 PST
 
The help would be appreciated.  However I have nowhere to readily post
a page for you.  The background to be printed in the specific instance
that prompted the request is just from styling on a table row:
<table>
<tr style='background-color:#E0E0E0;'>
<td>Example</td>
</tr>
</table>
Subject: Re: Printing background in Internet Explorer (scripted)
From: georgelawrence-ga on 04 Nov 2005 12:57 PST
 
Cool.  I'll mock something up and post it here later on tonight. 
Hopefully it'll help you.
Subject: Re: Printing background in Internet Explorer (scripted)
From: georgelawrence-ga on 07 Nov 2005 00:45 PST
 
Sorry, Didn't get a chance to get back to this until now.  Anyway...

The aproach I took was to paint the grey "background" as an image and
not as a background at all.  I Googled around and found a simple grey
gif.  (If you use this approach, you'll of course want to serve this
from your own servers.)  Then I position the text of the header
directly over the grey image.  This way the "print backgound colors"
setting of the browser doesn't matter, because the background's not a
background at all.

Example...

<html>
<table>
<tr>
<td>
<div style="height:1.4em;overflow:hidden">
<div style="height:1.4em"><img style="height:100%;width:100%"
src="http://art.sdsu.edu/geninfo/homepages/art240/lessons/vector/images/grey.gif"/></div>
<div style="height:1.4em;position:relative;top:-1.4em;;margin-left:2px;margin-top:2px">Header
Text</div>
</div>
</td>
</tr>
<tr><td>In the table cell of the header above there are 3 divs...</td></tr>
<tr><td>1) The first one encloses the next two</td></tr>
<tr><td>2) The next one contains a grey gif which is streched to fill
the div</td></tr>
<tr><td>3) The next one is positioned on top of the previous one and
contains the text</td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td>Note, some versions of IE ignore the overflow css setting when
printing.</td></tr>
<tr><td>This causes a bit of unwanted space underneath the header.</td></tr>
<tr><td>Firefox doesn't seem to have a problem with it.</td></tr>
<tr><td>&nbsp;</td></tr>
</table>
</body>
</html>
Subject: Re: Printing background in Internet Explorer (scripted)
From: rahulvaja-ga on 03 Dec 2005 08:47 PST
 
I'm currently working on print style sheets for my website, and using a
javascript:window.print(); link as well. No issues here with it picking
up the right style sheet. If it is of any help at all, this is the
stylesheet code that I am using:

<style type="text/css" title="Style by CSS for screen" media="screen">
	@import "displayhtml.css";
</style>

<style type="text/css" title="Style by CSS for printer" media="print">
	@import "printhtml.css";
</style>

I did notice problems early on if I didn't specify 'media="screen"' for
the basic style sheet. What would happen is both style sheets would be
applied when printing, rather than just the print stylesheet --resulting
in some seriously jumbled display.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy