0

I have the following JavaScript print function that prints whatever inside my panel in ASP.NET:

   function PrintPanel() {
        var panel = document.getElementById("<%=pnlContents.ClientID %>");
        var printWindow = window.open('', '', 'height=400,width=800');
        printWindow.document.write('<html><head><title></title>');
        printWindow.document.write('</head><body >');
        printWindow.document.write(panel.innerHTML);
        printWindow.document.write('</body></html>');
        printWindow.document.close();
        setTimeout(function () {
            printWindow.print();
        }, 500);
        return false;
    }

<asp:Button ID="btnPrint" runat="server" Text="Print" OnClientClick = "return PrintPanel();" Height="34px" Visible="False" Width="69px" />

The problem is, it is print the page link, date and the page number. is there a way I can hide them? I am thinking to make the text white so they do not show up, but still not sure here should I edit that, any suggestion are appreaciated. Thank you.

user3345212
  • 131
  • 1
  • 5
  • 15

1 Answers1

0

You're talking about the information that prints at the edges of the page, correct? This question will get you about as close as you can probably get. Note that it doesn't appear to be absolute, as the user will likely be able to change around settings when they use the print dialog in their browser.

But, outside of that, I think you're getting a bit too complex with printing. If your goal is to make a page that will only print the main content, you should use the @media CSS rule and simply mark elements you don't want printed with display:none. You can still have your print button, but you don't need to capture anything or open a new window.

Community
  • 1
  • 1
Kodithic
  • 160
  • 12