PDA

View Full Version : Help with - Alternate document for printing



creelove
10-10-2006, 02:04 PM
1) Script Title: Alternate document for printing

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex9/printstyle.htm

3) Describe problem: This doesn't seem to work in my browser. I'm running IE version 6.0 This script didn't work in my page and I did it exactly how it is in the script, so then I decided to see if it worked on your page and I got the same result. It prints a blank page with the URL at the bottom (which actually does say the other document - printversion.doc) but that's it. Any help would be appreciated!! Thanks!

jscheuer1
10-10-2006, 03:42 PM
This is outdated and only works in IE. If you were to use a valid HTML page (with the .htm or .html extension) instead of a .doc, it might work in IE. The current cross browser method is to use a print stylesheet:


<link rel="stylesheet" media="print" href="print.css">

The file print.css would contain alternate styles for printing the page, not an alternate document. In print.css you could set the display property of those sections of the document that you don't want to be printed to none:


.noprint {
display:none;
}

Then anything you don't want printed on the page could be like:


<p class="noprint">This won't get printed</p>

You are not limited to just the display property. You can alter the style of elements and still have them print (let's say the body of your page is usually white text on a blue background, not so hot for printing):



body {
color:black;
background-color:white;
margin:0;
padding:0;
}

You can also include printer only styles in an ordinary stylesheet like so:


@media print {
body {
color:black;
background-color:white;
margin:0;
padding:0;
}
}

creelove
10-10-2006, 03:47 PM
I need to print a pdf version to be compliant - is there no way at all to do that? In my other html files I do have the css for printing, but for the products they ONLY want the pdf version to be printed....any other thoughts?

jscheuer1
10-10-2006, 04:08 PM
Well, .pdf depends upon the user having a program configured for displaying/printing such files. Most folks have one but, it may be out of date, some folks may not have any. So, this is just a bad idea to begin with. It has nothing to do with compliance except to the misguided wishes of whoever is requiring it of you. You can have a link on the page to the .pdf version. You can have it be:


<a href="some.pdf">.pdf version for printing</a><br>
Need a .pdf reader/printer?<br>
<a href="http://www.adobe.com/products/acrobat/readstep2.html">Free Adobe Acrobat .pdf reader/printer</a>

You could also set the print style display property for the page to none.

This is about as close as you can come.

I'd experiment with making everything on the page display:none; for printing except an iframe that contains the .pdf version:


<iframe style="width:100%;height:100%;display:none;" src="some.pdf"></iframe>

Set its style to display:inline; for printing but, I'm not sure that this would work out too well in actual practice.