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
2009-10-09 20:28:09
Wait, what? I'm pretty sure I've used @media selectors successfully with IE 6 just fine in the past.
Joel Coehoorn
2009-10-09 20:35:44
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
2009-10-09 20:37:09
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
2009-10-09 20:45:19
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
2009-10-09 20:45:38
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
2009-10-09 21:27:35