Results 1 to 4 of 4

Thread: How to print HTML pages in landscape mode

  1. #1
    Join Date
    Nov 2008
    Posts
    1,221

    How to print HTML pages in landscape mode

    I want to print HTML pages programmatically in landscape mode. I want to make it such that it happens automatically without any user intervention. Is this possible? Can I print pages through coding? I tried making a myPrint class but it doesn't allow to print. Does any one know how to do this?

  2. #2
    Join Date
    May 2008
    Posts
    945

    Re: How to print HTML pages in landscape mode

    JavaScript does not allow you to set the page orientation so you can print in Landscape mode. However you can fix this issue by adding this code in the <head> tag:

    HTML Code:
    <style type="text/css">
    @page
    {
    	size: landscape;
    	margin: 2cm;
    }
    </style>
    Then just add @media between the <style> tags in this code to allow the page to print in landscape mode: <style type="text/css" media="print">

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to print HTML pages in landscape mode

    To print the page in LANDSCAPE mode simply code like this:

    HTML Code:
    <script>
    var shell = null;
    function SetPrintProperties() {
    try {
    shell = new ActiveXObject("WScript.Shell");
    shell.sendKeys("^p");
    setTimeout("shell.sendKeys('%R')",1000);
    setTimeout("shell.sendKeys('%L')",1100);
    }
    catch (e) {
    alert ("An exception occured: " + e + "\nCode is: " + e.number + "\nDescription is: " + e.description);
    }
    }
    </script>

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    Re: How to print HTML pages in landscape mode

    It is possible to print HTML pages in landscape mode manually, just adjust the browsers printer settings. For example, in Firefox, go to File > Page Setup > Format > Orientation.

    However for coding to achieve this is not possible with the help of html, css or javascript.

Similar Threads

  1. Replies: 3
    Last Post: 27-02-2012, 10:21 AM
  2. Unable to print HTML pages from Internet explorer 9 or Outlook 2003
    By Chengelpet in forum Technology & Internet
    Replies: 11
    Last Post: 02-12-2011, 10:06 PM
  3. How to print html page with the print dialogue
    By Gefry in forum Software Development
    Replies: 3
    Last Post: 27-07-2009, 11:06 AM
  4. How to print a webpage in landscape mode?
    By gazwsx in forum Technology & Internet
    Replies: 5
    Last Post: 10-07-2009, 06:13 PM
  5. Replies: 3
    Last Post: 05-06-2009, 04:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,716,224.06574 seconds with 17 queries