locked
Hiding URL, time/date and page number while printing an ASP.NET page RRS feed

  • Question

  • User1478071981 posted

    Hi,

    I developed a web application with which it is possible to generate a QR Code that an user can print.
    The QR Code is generated through a bitmap that is assigned to a PlaceHolder:

     <div id="dvBarCode" class="modal-footer" style="display: none">
       <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>                     
     /div>

    then a Javascript is called "code-behind":

     function ClientSidePrint(idDiv) {
                var w = 100; //600;
                var h = 100; //400;
                var l = (window.screen.availWidth - w) / 2;
                var t = (window.screen.availHeight - h) / 2;
    
                var sOption = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=" + w + ",height=" + h + ",left=" + l + ",top=" + t;
                // Get the HTML content of the div
                var sDivText = window.document.getElementById(idDiv).innerHTML;
                // Open a new window
                var objWindow = window.open("", "Print", sOption);
                // Write the div element to the window
                objWindow.document.write(sDivText);
                objWindow.document.close();
                // Print the window            
                objWindow.print();
                // Close the window
                objWindow.close();           
                
            }

    where "idDiv" is "dvBarCode" (the "div" that contains the PlaceHolder).
    Everything works and the QR Code is printed but also time/date, page number and url of the page are printed: since the QR Code should be printed on a label printer (Dymo), is there a way to print ONLY the QR Code and not also the other info?
    Thanks, regards.

    Roberto

    Monday, November 30, 2020 3:40 PM

Answers

  • User1535942433 posted

    Hi washburn_it,

    Accroding to your description, the header with the URL (and sometimes the page title, page number etc.) is automatically added by the web browser. Basically the settings can only be changed by the user.

    But the CSS standard enables some advanced formatting, you can refer the following post.

    https://stackoverflow.com/questions/1960939/disabling-browser-print-options-headers-footers-margins-from-page

    Also, you can change the setting from the print dialog. Under the header and footer setting you can change the print setting.

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 1, 2020 2:35 AM

All replies

  • User1535942433 posted

    Hi washburn_it,

    Accroding to your description, the header with the URL (and sometimes the page title, page number etc.) is automatically added by the web browser. Basically the settings can only be changed by the user.

    But the CSS standard enables some advanced formatting, you can refer the following post.

    https://stackoverflow.com/questions/1960939/disabling-browser-print-options-headers-footers-margins-from-page

    Also, you can change the setting from the print dialog. Under the header and footer setting you can change the print setting.

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, December 1, 2020 2:35 AM
  • User1478071981 posted

    Hi,

    following the link I "fixed" the problem with the CSS solution.
    Thanks a lot, regards.

    Roberto

    Friday, December 4, 2020 8:09 AM