Print every HTML page

Asked

Viewed 181 times

0

I made a simple function to print the content of my site by clicking a button, but when clicking the button (Ctrl+p) the images of the site do not appear, only the content... Only appearing if user presses "Show Background Chart" in Google Chrome print window.

My idea is that the user can print direct from Smartphone, but this option to enable graphics in the background does not appear on mobile phones.

Does anyone know if there is any way that the browser does not understand that the images are graphics in the background ? Is there any special CSS I should put in @print that can configure this ?

Thank you very much!

  • 1

    These images are using the <img> tag or these images are background-img?

1 answer

1

You can use the property -webkit-print-color-adjust: exact;, but, as the documentation informs, it is not a standardized property and may not work on all browsers or devices.

Testing on Chrome, it worked, but not on Firefox. You can check the compatibilities on the site Can I Use:

inserir a descrição da imagem aqui

It is necessary to keep in mind that the programmer/developer does not have full control over the browser, and many things only occur by the direct action of the user. Sometimes you have to resort to other methods. In your case, you could use another way to display the images, such as putting them directly into HTML floating under the content. So you wouldn’t have to worry about that printing part.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.