printing in black and white

Anjali Agarwal 1,386 Reputation points
2021-09-17T02:41:06.027+00:00

I need to print the contents between two div tags. The printing is done fine, but somehow if the user checks the "Background Graphics" checkbox in the printing pop up then the background becomes blue which is the actual background color of the web page. Is it possible to force the user to print only in black and white or disable the "Background Graphics" checkbox from the pint pop up? Below is the image of the "Background Graphics" check box that I am talking about:

XoFGI.png

I also tried putting this in the page:

<style>
article {
  -webkit-print-color-adjust: exact;
  background: #222;
  color: #eee;
}

</style>

Below is my div tag:

<div>
 The contents needs to be printed. This is just a test.
</div>

this is the button that calls the print function:

 <asp:LinkButton Width="130px" Height="50px" ID="print" CssClass="btns" runat="server" OnClientClick="printContent('dvContents');return false;" </asp:LinkButton>

any help will be greatly appreciated.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,417 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 28,841 Reputation points Microsoft Vendor
    2021-09-20T06:55:48.193+00:00

    Hi @Anjali Agarwal ,
    I suggest you modify the printer settings.
    Maybe you can set two buttons, first set the content you need to print to black and white, and then change it back.


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Lan Huang

    0 comments No comments