zoukankan      html  css  js  c++  java
  • 打印设定区域

       在很多客户请求中,有些字据要进行打印,比如一些发票或一些具体的详情信息需要打印。具体直接上代码:

    页面代码:

     <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
             aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog" style="background-color:#99cadb; ">
                <div class="modal-header" style="background-color: #99cadb;" >
                  <button class="btn btn-sm btn-primary" ng-click="doPrintdetail()">  打印数据</button>
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                </div>
                <!--startprint-->
                <div class="modal-dialog">
                <div class="modal-content">
    
                    <h2 class="modal-title" id="myModalLabel">
                        详情信息
                    </h2>
                    <div class="modal-body">
                        <table>
                            <tr><td></td><td>商户ID</td><td></td>
                     <td >{{currentCoupons.merchantRoleId}}</td></tr> <tr><td></td><td">优惠券类型</td><td></td>
    <td id="coupontypeTime" >免费{{currentCoupons.freeTime}}小时</td> <td id="coupontypeMoney">免费{{currentCoupons.money}}元</td> <td id="coupontypeallfree">全额免费</td> <td id="coupontypealltime">最大免费时长</td> </tr> </table> </div> </div> </div> <!--endprint--> </div> </div> </div>
    <!--startprint--> <!--endprint--> 一定要填写的,这是标志文件打印的起始

    js代码:
     $scope.doPrintdetail=function() {
            bdhtml=window.document.body.innerHTML;
            sprnstr="<!--startprint-->";
            eprnstr="<!--endprint-->";
            prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
            OpenWindow = window.open("");
            //OpenWindow.document.write("<link rel="stylesheet" type="text/css" href="/parkmanage-new/css/printdetail.css">");
            OpenWindow.document.body.innerHTML=prnhtml;
            OpenWindow.print();
        };
  • 相关阅读:
    大小端表示法
    构建二叉树并求其深度
    输入一行字符反向输出
    C++读取一行字符串输入
    关于递归调用的深度
    2016-9-22题目:extern char* 与char[]
    Ubuntu安装搜狗输入法
    判断字符串相等
    [Warning] deprecated conversion from string constant to 'char*' 原因
    ArcGIS API for JavaScript 4.2学习笔记[31] (补充学习)Task类
  • 原文地址:https://www.cnblogs.com/liziyou/p/6498981.html
Copyright © 2011-2022 走看看