Print Styles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Olson

    Print Styles

    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?


  • Mark Preston

    #2
    Re: Print Styles

    Terry Olson wrote:
    [color=blue]
    > 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?
    >[/color]
    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.

    Comment

    • Grant Wagner

      #3
      Re: Print Styles

      Terry Olson wrote:
      [color=blue]
      > 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?[/color]

      <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.

      --
      Grant Wagner <gwagner@agrico reunited.com>
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      • Terry Olson

        #4
        Re: Print Styles

        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?

        "Grant Wagner" <gwagner@agrico reunited.com> wrote in message
        news:4162AC8D.5 5F76689@agricor eunited.com...[color=blue]
        > Terry Olson wrote:
        >[color=green]
        > > 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?[/color]
        >
        > <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.
        >
        > --
        > Grant Wagner <gwagner@agrico reunited.com>
        > comp.lang.javas cript FAQ - http://jibbering.com/faq
        >[/color]


        Comment

        • Michael Winter

          #5
          Re: Print Styles

          On Tue, 05 Oct 2004 14:13:04 GMT, Grant Wagner
          <gwagner@agrico reunited.com> wrote:

          [snip]
          [color=blue]
          > <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".[/color]

          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

          --
          Michael Winter
          Replace ".invalid" with ".uk" to reply by e-mail.

          Comment

          • Terry Olson

            #6
            Re: Print Styles

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

            "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
            news:opsfekovgc x13kvk@atlantis ...[color=blue]
            > On Tue, 05 Oct 2004 14:13:04 GMT, Grant Wagner
            > <gwagner@agrico reunited.com> wrote:
            >
            > [snip]
            >[color=green]
            > > <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".[/color]
            >
            > 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
            >
            > --
            > Michael Winter
            > Replace ".invalid" with ".uk" to reply by e-mail.[/color]


            Comment

            • Michael Winter

              #7
              Re: Print Styles

              On Tue, 05 Oct 2004 16:48:00 GMT, Terry Olson <twjolson@hotma il.com> wrote:
              [color=blue]
              > Getting closer, but I'm coding specifically for IE, does it support any
              > of this @page rule?[/color]

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

              [snip]

              Mike


              Please don't top-post.

              --
              Michael Winter
              Replace ".invalid" with ".uk" to reply by e-mail.

              Comment

              Working...