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