如何打印默认情况下,在横向模式下

时间:2018-05-28 12:25:20

标签: javascript html css angularjs

我如何在默认横向模式下进行打印。如果我以横向模式提供其打印仅作为纵向模式。

我尝试了以下代码。那个也行不通。



@media print{@page {size: landscape}}




请找到图片。我该如何解决这个问题。我只想显示我在文本框中输入的文本。请帮助我如何解决这个问题。

jsfiddle



 $scope.print = function(divName,secondDiv){
  	    $timeout(function () {
  	    var printContents = document.getElementById(divName).innerHTML;
  	  var printContents1 = document.getElementById(secondDiv).innerHTML;
  	  
  	    console.log(printContents);
  	    
  	      var w = window.open();
  	      w.document.open();
  	    $timeout(function(){
  	      w.document.onreadystatechange=function(){
  	         if(this.readyState==='complete'){
  	          this.onreadystatechange=function(){};
  	          w.focus();
  	          w.print();
  	          w.close();
  	         }
  	      }
  	    },1000);
  	    
  	      w.document.write('<!doctype html><html><head><title>');
  	      w.document.write('</title><link rel="stylesheet" type="text/css" href="css/main.css" /><link rel="stylesheet" type="text/css" href="css/docs.css" /><link rel="stylesheet" type="text/css" href="css/angular-material.css" /></head><body onload="window.print();window.close()"  style="font-size:14px;" ng-app="app" class="" ng-controller="mainController" >');
  	      w.document.write(printContents+printContents1); //only part of the page to print, using jquery
  	      w.document.write('</body></html>');
  	      w.document.write('<style>@media print {  input { border: none !important;text-align:right!important;font-size:12px!important;margin-top:2px!important; }  th,td{height:3px!important;position:relative;} }</style>');
  	      w.document.close(); //this seems to be the thing doing the trick
  	      }, 1000);
  	    }
&#13;
<div ng-hide="true" class="rec_wrapper" id="printableArea"
					style="margin-top: 0px; width: 100%;">
<table class="makeWidth" border="1" style="border-collapse:collapse;">
<tr>
	<td>				
<table class="first" width="782"  border="1" style="border-collapse:collapse;height:10px;">
  <tr>
    <td width="702">
    <div align="center"><strong><b>Challan For Cash Deposit in Any Branch Of SBI (Power Jyothi)</b></strong></div>
   <p style="text-align:center">CUSTOMER COPY</p>
    </td>
  </tr>
</table></br>

<p style="margin-top:1px;"><strong><b> Bank Of </b> <b><u>Branch Coimbatore</u></b></strong> Branch</p>
<p style="margin-top:0px;"><strong>Date <b><u>  </u> </b> </strong></p>
<p style="margin-top:0px;">For the Credit of <strong><b></strong></b></p>


<p style="margin-top:0px;">Depositor's Name : <strong><u> <input type="text" class="input printText1" ng-model="depositorName" style="font-weight:900;font-size:10px"  value={{depositorName}} placeholder="Depositor Name"></u></strong> </p>
<p style="margin-top:0px;">Depositor's Mobile No :<strong><u> <input id="depositNum" type="number" class="input printText" ng-model="depositorNo" style="font-weight:900;font-size:10px"  value={{depositorNo}} placeholder="Depositor mobile number"></u></strong> </p>
<p style="margin-top:0px;">Amount in Rs :<strong><b><u></u></b></strong> </p>
<p style="margin-top:0px;">Amount ( in Words) : <strong><b><u></u></b></strong> </p>
</hr>

<hr>
<table id="cashDetails" border="1" style="border-collapse:collapse;">
  <tr>
    <th colspan="3" style="text-align:center">Details of Cash</th>
  </tr>
  <tr>
    <td style="text-align:center;">Cash Notes</td>
    <td style="text-align:center;">Amount in Rs.</td>
   
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount" id="textBox2" value={{amount}}>X 2000</td>
    <td style="text-align:center">{{ (+amount) * 2000}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount1" id="textBox2" value={{amount1}}>X 500</td>
    <td style="text-align:center">{{ (+amount1) * 500}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount2" id="textBox2" value={{amount2}}>X 200</td>
    <td style="text-align:center">{{ (+amount2) * 200}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount3" id="textBox2" value={{amount3}}>X 100</td>
    <td style="text-align:center">{{ (+amount3) * 100}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount4" id="textBox2" value={{amount4}}>X 50</td>
    <td style="text-align:center">{{ (+amount4) * 50}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount5" id="textBox2" value={{amount5}}>X 20</td>
    <td style="text-align:center">{{ (+amount5) * 20}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount6" id="textBox2" value={{amount6}}>X 10</td>
    <td style="text-align:center">{{ (+amount6) * 10}}</td>
    
  </tr>
  
  <tr>
    <td style="text-align:left;">Coins</td>
    <td></td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount7" id="textBox2" value={{amount7}}>X 10</td>
    <td style="text-align:center">{{ (+amount7) * 10}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount8" id="textBox2" value={{amount8}}>X 5</td>
    <td style="text-align:center">{{ (+amount8) * 5}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()" ng-model="amount9" id="textBox2" value={{amount9}}>X 2</td>
    <td style="text-align:center;width:48%">{{ (+amount9) * 2}}</td>
    
  </tr>
  <tr>
    <td><input class="input printText" type="number" ng-change="calcTotal()"ng-model="amount10" id="textBox2" value={{amount10}}>X 1</td>
    <td style="text-align:center">{{ (+amount10) * 1}}</td>
    
  </tr>
  <tr>
    <td style="text-align:left;height:10px;">Total</td>
    <td style="text-align:center;height:20px">{{total}}</td>
    
  </tr>

</table></br></br></br></br></br>

<label style="margin-left:7px;">Cashier</label>
<label style="margin-left:90px;">Cash/Passing Officer</label>
<label style="margin-left:20px;">Depositor's Signature</label>

</td>
</tr></table>
</div></br></br></br>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

试试这可能会有效..

@page {
    size: A4 landscape;
}
相关问题