Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Markup (HTML, XHTML, XML) _ How to print an alternate page

Posted by: PIJoe Jan 22 2007, 11:10 PM

OK... I'm beyond frustration. I'm sure there is a SIMPLE fix to this....

I need to specify an alternate file for printing (instead of the webpage). What I'm actually doing is printing a coupon that is located in the center of the page and I don't want to print the rest of the page content. Several places make reference to this type of usage... for alternate languages, alternate devices, even specifically to get a "printer friendly" file to print instead of html

Assume the coupon is contained in a file called coupon.html (or .pdf or .txt or anything else that will work)

Based on what I read (and I have tried to figure this out....)

<link rel="alternate" media="print" href="coupon.html" /> SHOULD work... but it doesn't

you can also add ... type="text/css" but that is optional

I know how to set the coupon apart with a class and make only that class visible to a printer... but it prints in the same relative location and if it's a long webpage... you get two blank sheets with a coupon 2/3 of the way down on page one... not acceptable.


Posted by: pandy Jan 23 2007, 01:07 AM

QUOTE(PIJoe @ Jan 23 2007, 05:10 AM) *

Based on what I read (and I have tried to figure this out....)

<link rel="alternate" media="print" href="coupon.html" /> SHOULD work... but it doesn't


Which it shouldn't. The src should refer to a CSS files, not a HTML one. Are you sure you want this to be an alternate style sheet?

QUOTE
you can also add ... type="text/css" but that is optional

No, it's not optional.


QUOTE
I know how to set the coupon apart with a class and make only that class visible to a printer... but it prints in the same relative location and if it's a long webpage... you get two blank sheets with a coupon 2/3 of the way down on page one... not acceptable.


So how do you hide the content? 'visibility: hidden'? Try 'display: none' instead. If you want more constructive advice, please link to an example page so we can take a look at what you have.

I usually don't recommend a special page for print, but in this case I wonder if it wouldn't be the best. Normally you use a print style sheet to hide stuff that isn't meaningful on a printed page, like for instance navigation. In this case you hide content. What if someone wants to print the whole page and just gets your coupon?

Posted by: Brian Chandler Jan 23 2007, 02:04 AM

QUOTE(PIJoe @ Jan 23 2007, 01:10 PM) *


I need to specify an alternate file for printing (instead of the webpage). What I'm actually doing is printing a coupon that is located in the center of the page and I don't want to print the rest of the page content. Several places make reference to this type of usage... for alternate languages, alternate devices, even specifically to get a "printer friendly" file to print instead of html



(I presume this is for visitors to print the coupon, not something that you just do yourself.)

Keep it simple: put a link under the coupon "Print coupon", which goes to a page with just the coupon in; use javascript to put it in a new window, and automatically print onload (user will have to confirm). If the formatting of the coupon itself is at all complex, and particularly if it's just black and white, you could make the whole coupon an image. Use CSS to make it the right printing size, not forgetting that no country in the world with only about two exceptions has paper 8.5" wide, so make sure it fits on A4.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)