简体   繁体   English

打印 Scrollable Bootstrap Modal 在末尾添加额外的页面

[英]Printing Scrollable Bootstrap Modal adds extra pages at the end

I have a scrollable bootstrap modal with a print button on top of it.我有一个可滚动的引导模式,上面有一个打印按钮。 When user clicks it, i'm printing the modal.当用户单击它时,我正在打印模态。 Below is the code, HTML :下面是代码,HTML:

<div class="container-fluid" id="body-noPrint">
    /* HTML BODY CONTENT */
</div>

<div id="print-content">
     <!--PRINT PREVIEW MODAL MARKUP-->
        <div class="modal fade" id="printViewModal" tabindex="-1" role="dialog">
              <div class="modal-dialog">
                    <div class="modal-content">
                          <div class="modal-header">                                
                                <button type="button" class="btn btn-primary pull-right" id="modal-Printbtn"><span class="glyphicon glyphicon-print" aria-hidden="true"></span> Print</button>
                          </div><!--MODAL HEADER CLOSE-->
                          <div class="modal-body">
                              <!--DISPLAY THIS ROW AT MODAL VIEW-->
                                <div class="row">
                                        /* HEADER UI */                     
                                </div><!--MODAL VIEW HEADER CONTENT CLOSE-->

                              <!--DISPLAY THIS ROW AT PRINT-->
                                <div class="row" style="display:none;"> 
                                        /* HEADER PRINT */
                                </div><!--PRINT VIEW HEADER CONTENT CLOSE-->

                              <!--PRINT VIEW DYNAMIC TABLE-->
                                <div class="table-responsive" id="modalTable">
                                    <table id="modalTbl" class="table table-bordered">
                                      <thead>
                                        <tr class="active">
                                            <th class='col-xs-6'></th>
                                            <th class='col-xs-1'></th>
                                            <th class='col-xs-5'></th>
                                        </tr>
                                      </thead> 
                                      <tbody>               
                                      </tbody>           
                                    </table>                            
                                </div>                                                                                        
                        </div>                
                    </div>
              </div>
        </div>
</div>

JS : JS:

$('#prntBtn').click(function(){
    window.print();
});

CSS : CSS :

@media print{
  /* Below CSS Makes Modal Content Visible At Print */
    body.modal-open {
        visibility: hidden;
    }

    body.modal-open .modal .modal-header,
    body.modal-open .modal .modal-body {
        visibility: visible;  /* make visible modal body and header */
    }

    body.modal-open .modal {
        position: absolute;
        left: 0;
        top: 0;
        margin: 0;
        padding: 0;
        overflow: visible!important;
    }

/*Print Preview Modal Styling CSS*/    
    #printViewModal .modal-dialog {
      width: 100%;
      height: 100%;
      margin: 0;
      padding: 0;
    }

    #printViewModal .modal-content {      
      height: 100%;
      border-radius: 0;
      overflow:auto;
    }

    #printViewModal *{
        font-size:x-small !important;
    }

    #modalTbl thead tr > th{
        text-align:center;
    }

    #modalTbl tbody tr > td{
        text-align:left;
    }

    #modalTable{
        margin-top:10px;
    } 
}

I got a suggestion from stack overflow to replace 'visibility : hidden', for that i tried 'display : none', but this displays blank page at print.我从堆栈溢出中得到了一个建议来替换“可见性:隐藏”,为此我尝试了“显示:无”,但这在打印时显示空白页。

Can someone please help me, in getting rid of these extra pages when printing.有人可以帮助我,在打印时摆脱这些额外的页面。

You can enable this option [Background graphics] to see what is extra printed on your page.您可以启用此选项 [背景图形] 以查看页面上额外打印的内容。 Hope this helps to find out the root cause.希望这有助于找出根本原因。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM