Print Styles

T

Terry Olson

I need to create a Javascript and when the output is printed, I need to
control the margins of the printed page very strictly, can Internet
Explorers version of CSS do this? Or is there another solution?
 
M

Mark Preston

Terry said:
I need to create a Javascript and when the output is printed, I need to
control the margins of the printed page very strictly, can Internet
Explorers version of CSS do this? Or is there another solution?
Be fair, Internet Explorer doesn't print *any* pages properly at the the
best of times! Make it *right* and if MSIE fouls it up, blame Microsoft.
After all, it really *is* their fault.
 
G

Grant Wagner

Terry said:
I need to create a Javascript and when the output is printed, I need to
control the margins of the printed page very strictly, can Internet
Explorers version of CSS do this? Or is there another solution?

<style type="text/css">
@media print {
margin-left: 6em;
margin-right: 6em;
}
</style>

Note those are the document margins, _not_ the printed page margins. What
that means is that if the browser is configured with a 1" margin on the
page, the above CSS will add a 6em margin inside of that 1". You can not
control the attributes of the actual printed page using client-side
JavaScript in the default security environment without help from something
like ScriptX from Meadroid.

See <url: http://jibbering.com/faq/#FAQ4_23 /> for more information.
 
T

Terry Olson

Those links are a start, but I need it all in one file html file. I'm
guessing I'm out of luck then huh?
 
M

Michael Winter

On Tue, 05 Oct 2004 14:13:04 GMT, Grant Wagner

[snip]
<style type="text/css">
@media print {
margin-left: 6em;
margin-right: 6em;
}
</style>

Note those are the document margins, _not_ the printed page margins.
What that means is that if the browser is configured with a 1" margin on
the page, the above CSS will add a 6em margin inside of that 1".

You can use the the CSS page at-rule (@page) to specify the page size and
margins. In such a rule, font units, such as em and ex, are not allowed.
I'd also question the suitability of px, but it's not explicitly
mentioned. If percentages are used for the margins, they are relative to
the size of the page. See <URL:http://www.w3.org/TR/REC-CSS2/page.html>
for more information.

@page {
/* A4 */
size: 21cm 29.7cm;
/* 2.1cm left/right margins, 2.97cm top/bottom */
margin: 10%;
}

Of IE, Mozilla (Suite and Firefox), and Opera, only Opera supports this.

I suppose there isn't much point in including this in the FAQ until more
support is acheived.

[snip]

Mike
 
T

Terry Olson

Getting closer, but I'm coding specifically for IE, does it support any of
this @page rule?

Michael Winter said:
On Tue, 05 Oct 2004 14:13:04 GMT, Grant Wagner

[snip]
<style type="text/css">
@media print {
margin-left: 6em;
margin-right: 6em;
}
</style>

Note those are the document margins, _not_ the printed page margins.
What that means is that if the browser is configured with a 1" margin on
the page, the above CSS will add a 6em margin inside of that 1".

You can use the the CSS page at-rule (@page) to specify the page size and
margins. In such a rule, font units, such as em and ex, are not allowed.
I'd also question the suitability of px, but it's not explicitly
mentioned. If percentages are used for the margins, they are relative to
the size of the page. See <URL:http://www.w3.org/TR/REC-CSS2/page.html>
for more information.

@page {
/* A4 */
size: 21cm 29.7cm;
/* 2.1cm left/right margins, 2.97cm top/bottom */
margin: 10%;
}

Of IE, Mozilla (Suite and Firefox), and Opera, only Opera supports this.

I suppose there isn't much point in including this in the FAQ until more
support is acheived.

[snip]

Mike
 
M

Michael Winter

Getting closer, but I'm coding specifically for IE, does it support any
of this @page rule?

IE lacks most of the new features of CSS 2. That includes the page at-rule.

[snip]

Mike


Please don't top-post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top