views:

694

answers:

1

I have a need to print pages from a webap on to 8x4 index cards. IE doesn't save print settings from one print to the next, so is there a way to programatically force the print set up?

+6  A: 

You can do this in CSS using the @media print directive, no js required. You'll have to calculate what sizes relate to a 4x8 index card and do all the positioning yourself, but it will work. Also, since this is CSS2 it won't work in IE6. (see Joel's comments)

@media print {
  body {
    width: /*width of index card*/
    height: /*height of index card*/
  }
  /* etc */
}
tj111
Wait, what? I'm pretty sure I've used @media selectors successfully with IE 6 just fine in the past.
Joel Coehoorn
This page seems to indicate it works with IE as far back as version 4: http://www.codestyle.org/css/media/print-BrowserSummary.shtml
Joel Coehoorn
CSS supports inches as a unit of measurement for height and width as well... so @media print { body { width: 4in; height: 8in; } /* etc */}Should work fine, no>
Chris Sobolewski
Or, at least that it _can_ work that far back. Some of the edge cases break down, even in later versions. +1 anyway: using CSS is the right way to do this.
Joel Coehoorn
This won't force the paper size, but will print to a specified size, I think this is different. If you want to specify the page size, use the @page selector and the size attribute (CSS3: http://www.w3.org/TR/css3-page/#page-size)
Fabien Ménager