specifying page setup for printing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ally
    New Member
    • Dec 2009
    • 7

    specifying page setup for printing

    Hi,

    I'm having a page in which table get dynamically generated. It can have any number of columns at run-time. I have a print button to print it, its working fine till now what I want is to set page orientation and margins depending on the number of columns like if columns are more than 12 than page orientation should be Landscape else Portrait and according to that setting margins of the page.

    Is it possible?
    It'll be really a good help.

    Thanks in advanced.
  • semomaniz
    Recognized Expert New Member
    • Oct 2007
    • 210

    #2
    as far as i know you can use javascript to print the current page but i am not sure there is a way to change the page setup using javascript. You can always use different css style sheets to have the print out look better but again having to many columns might be a problem.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      There is a way to specify the page. You use CSS to do this.
      It's actually pretty cool. You make one CSS style sheet to use to display your content in the web browser, and then you make another CSS style sheet to specify how your content should look when it's printed. You use the media type to specify what the style sheet is used for. When you create a print style sheet you can hide things like buttons and images....you can completely change the way it looks if you need to.

      Check it out:


      -Frinny

      Comment

      • semomaniz
        Recognized Expert New Member
        • Oct 2007
        • 210

        #4
        @ Frinny -- not that i am questioning you but is there a way to change the page setup to Landscape or Portrait using a script? I am aware that we can use css to change the format of the displayed data to print but i have never been able to change the page setup. If there is a way i will be certainly learning something new :-)

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          I haven't done it myself but you can specify that the page should be printed as portrait or landscape.

          According to the W3C: CSS Print Profile you can use the size property to specify which way the page should be printed.

          You don't need to use a script for this (well you could use a little bit of script... the JavaScript print() function is really helpful if you want to provide print functionality to the page). But if the user just uses the browser menu and selects Print the CSS page will be used. The print CSS style will always be used regardless of how the user prints the page.

          -Frinny

          Comment

          • semomaniz
            Recognized Expert New Member
            • Oct 2007
            • 210

            #6
            i am gonna give it a try after work for sure. coz i struggled printing reports so i ended up creating pdf files, this will certainly ease my work if it works

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Let me know how it goes. Like I said, I've never used it myself but it looks like it should work.

              -Frinny

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                Did this work?

                -Frinny

                Comment

                • ally
                  New Member
                  • Dec 2009
                  • 7

                  #9
                  specifying page setup

                  Hi frinny,

                  I got busy in some other work. I just specified page margins through css. I didn't try specifying page setup and using size property. If I get time I'll surely try using it.

                  Thanks for your support :)

                  Comment

                  Working...