locked
Print page using javascript RRS feed

  • Question

  • User-712926555 posted

    Hi,

    I am using window.print() for my bill in 3 inch printer

    <style type="text/css">
            body { background-color: #fff !important; font-family: Arial Black; font-size: 14px; }
    .cTitle
            {
                font-size: 30px;
            }
        </style>
        
        <script type="text/javascript">
            function PrintPage() {
               
                window.resizeTo(960, 600);
                document.URL = "";
                window.location.href = "";
                window.focus();
                window.print();
                
            }
    
            $(document).ready(function () {
                PrintPage();
            });
    
        </script>
    <style type="text/css">
            body { background-color: #fff !important; font-family: Arial Black; font-size: 14px; }
    .cTitle
            {
                font-size: 30px;
            }
        </style>
        
        <script type="text/javascript">
            function PrintPage() {
               
                window.resizeTo(960, 600);
                document.URL = "";
                window.location.href = "";
                window.focus();
                window.print();
                
            }
    
            $(document).ready(function () {
                PrintPage();
            });
    
        </script>
    
    
    
     <p style="line-height: 20px; text-align: center; width: 100%;">
                    <asp:Label ID="lblTitle" runat="server" Text="" CssClass="cTitle"></asp:Label>
    </p>
    
    <asp:ListView ID="lstBill" runat="server">
                    <LayoutTemplate>
                        <table class="lstviewClass" width="90%" cellpadding="0" cellspacing="0">
                            <thead>
                                <tr>
                                    <th>
                                        S.No
                                    </th>
                                    <th style="width: 50px; height: 2px; overflow: hidden;">
                                        Product
                                    </th>
                                    <th>
                                        Size
                                    </th>
                                    <th>
                                        Qty
                                    </th>
                                    <th>
                                        Rate
                                    </th>
                                  
                                    <th>
                                        Total
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                                <asp:PlaceHolder ID="ItemPlaceHolder" runat="server"></asp:PlaceHolder>
                            </tbody>
                        </table>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <tr>
                            <td width="20px">
                                <asp:Label ID="lblIndex" runat="server" Text='<%# Container.DataItemIndex + 1 %>' />
                            </td>
                            <td width="80px">
                                <asp:Label ID="Label2" runat="server" Text='<%#Eval("ProductName") %>' Height="20px"
                                    Style="overflow: hidden;" />
                            </td>
                            <td width="20px">
                                <asp:Label ID="Label6" runat="server" Text='<%#Eval("Size") %>' />
                            </td>
                            <td width="20px">
                                <asp:Label ID="lblAmount" runat="server" Text='<%#Eval("Quantity") %>' />
                            </td>
                            <td>
                                <asp:Label ID="Label5" runat="server" Text='<%# String.Format("{0:n0}", Eval("MRP")) %>' />
                            </td>
                           
                            <td>
                                <asp:Label ID="Label1" runat="server" Text='<%# String.Format("{0:n0}", Eval("Total")) %>' />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:ListView>
    
                <p class="cTitle">
    Grand Total : Rs. <asp:Label ID="lblTotAmount" runat="server" Text="" /> </p>


    from this code my cTitle class not print in chrome (i.e my shop name and Total amount). if it's firefox its printing. This issue from yesterday itself in chrome. I have change font family, font size, but no use. 

    How to solve it. Issue only in chrome. (My chrome Version 54.0.2840.71 m) 

    pls Help me. 

    Thursday, October 27, 2016 6:36 AM

All replies

  • User-1838255255 posted

    Hi Hisanth,

    According to your description and Code , I have tested your code in chrome  ,

    1. I found your code run perfect in the same version of chrome . Here is Result Screenshot:

    2.If you provide code is not  all ,it may be limited by other css .  As far as  l know , you could try add  ! important in this class css , this property can improve css priority , like this:

    .cTitle {
                font-size: 30px !important;           
            }
    

    Best Regards,

    Eric Du

    Friday, October 28, 2016 4:36 AM