Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 19-05-2009
Member
 
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?
Reply With Quote
  #2  
Old 19-05-2009
Member
 
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">
Reply With Quote
  #3  
Old 19-05-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
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>
Reply With Quote
  #4  
Old 19-05-2009
Member
 
Join Date: May 2008
Posts: 2,008
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to print HTML pages in landscape mode"
Thread Thread Starter Forum Replies Last Post
Pages cut off when using Google Cloud Print to print from HP PSC1315xi printer Shoana Technology & Internet 3 27-02-2012 10:21 AM
Unable to print HTML pages from Internet explorer 9 or Outlook 2003 Chengelpet Technology & Internet 11 02-12-2011 10:06 PM
How to print html page with the print dialogue Gefry Software Development 3 27-07-2009 11:06 AM
How to print a webpage in landscape mode? gazwsx Technology & Internet 5 10-07-2009 06:13 PM
How to print one page in portrait and other landscape in Excel Nathen Windows Software 3 05-06-2009 04:52 PM


All times are GMT +5.5. The time now is 12:40 PM.