【问题标题】:How to print a small bill receipt jquery php [duplicate]如何打印小账单收据jquery php [重复]
【发布时间】:2019-01-02 03:31:44
【问题描述】:

当我尝试打印一张小收据时,我遇到了打印问题。所有文件都显示打印。当我点击打印按钮时。打印后,文件打印按钮也打印在页面上。我只需要在页面上打印收据。我使用了 window.print();用于打印。

 <div class="container">
        <div class="row">
            <div class="col-xs-12">
                <div class='print' style="border: 1px solid #a1a1a1; width: 300px; background: white; padding: 10px; margin: 0 auto; text-align: center;">

                    <div class="invoice-title" align="center">

                        <h1>Pepsi Cola</h1>
                    </div>

                    <div class="invoice-title" align="left">
                        Order #  &nbsp; &nbsp;<b> 11111</b>
                    </div>


                    <div class="invoice-title" align="right">
                        Invoice   <b>22344</b>
                    </div>
                    </br>
                    </br>

                    <div>
                        <div>
                            <table class="table table-condensed">
                                <thead>
                                <tr>
                                    <td class="text-center"><strong>No</strong></td>
                                    <td class="text-center"><strong>Pname</strong></td>
                                    <td class="text-center"><strong>Qty</strong></td>
                                    <td class="text-center"><strong>Price</strong></td>
                                    <td class="text-right"><strong>Total</strong></td>
                                </tr>
                                </thead>

                                <tr>
                                    <td class="text-center">
                                        1
                                    </td >
                                    <td class="text-center">
                                        Cake
                                    </td >
                                    <td class="text-center">
                                        2
                                    </td >
                                        <td class="text-center">120</td>
                                        <td class="text-right">240</td>
                                    </tr>
                            </table>
                        </div>
                    </div>
                    <div  align="right">
                        Sub Total &nbsp;&nbsp;<b>240</b>
                    </div>
                    <div align="right">
                        Pay  &nbsp;&nbsp; <b>220</b>
                    </div>
                    <div align="right">
                        Due &nbsp;&nbsp;   <b>20</b>
                    </div>
                    <input style="padding:5px;" value="Print Document" type="button" onclick="myFunction()"></input>
                </div>
                <div>
                    <div>
                    </div>

javascript

 <script>
        function myFunction()
        {
            window.print();
        }
    </script>

【问题讨论】:

  • “.我只需要打印收据”..您将页面的哪个部分归类为“收据”?从 HTML 中看不出来。无论如何,您可以使用特定于打印的 CSS(这是使用媒体查询实现的)来隐藏您在打印时不想要的页面位。你可以很容易地用谷歌搜索它。

标签: php jquery


【解决方案1】:

使用 CSS @媒体打印

function myFunction()
{
    window.print();
}
@media print
{
  .button
  {
    display: none;
  }
}
<div class="container">
        <div class="row">
            <div class="col-xs-12">
                <div class='print' style="border: 1px solid #a1a1a1; width: 300px; background: white; padding: 10px; margin: 0 auto; text-align: center;">

                    <div class="invoice-title" align="center">

                        <h1>Pepsi Cola</h1>
                    </div>

                    <div class="invoice-title" align="left">
                        Order #  &nbsp; &nbsp;<b> 11111</b>
                    </div>


                    <div class="invoice-title" align="right">
                        Invoice   <b>22344</b>
                    </div>
                    </br>
                    </br>

                    <div>
                        <div>
                            <table class="table table-condensed">
                                <thead>
                                <tr>
                                    <td class="text-center"><strong>No</strong></td>
                                    <td class="text-center"><strong>Pname</strong></td>
                                    <td class="text-center"><strong>Qty</strong></td>
                                    <td class="text-center"><strong>Price</strong></td>
                                    <td class="text-right"><strong>Total</strong></td>
                                </tr>
                                </thead>

                                <tr>
                                    <td class="text-center">
                                        1
                                    </td >
                                    <td class="text-center">
                                        Cake
                                    </td >
                                    <td class="text-center">
                                        2
                                    </td >
                                        <td class="text-center">120</td>
                                        <td class="text-right">240</td>
                                    </tr>
                            </table>
                        </div>
                    </div>
                    <div  align="right">
                        Sub Total &nbsp;&nbsp;<b>240</b>
                    </div>
                    <div align="right">
                        Pay  &nbsp;&nbsp; <b>220</b>
                    </div>
                    <div align="right">
                        Due &nbsp;&nbsp;   <b>20</b>
                    </div>
                    <input style="padding:5px;" value="Print Document" type="button" onclick="myFunction()" class="button"></input>
                </div>
                <div>
                    <div>
                    </div>

【讨论】:

  • 谢谢先生。但小票据打印机尺寸可以打印。
  • 不客气,请检查我的回答是否已回答。
  • 是的,谢谢,我看到了答案。太棒了,谢谢。我应该为 Pos Receipt-Printer 打印此页面
  • 这是否适用于 88mm 打印机....?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-17
  • 1970-01-01
相关资源
最近更新 更多