I am using window.print to save a web page as pdf ,and I put a background image for the body element to appear as watermark m my problem is when I click print for the first time the image not appeared , and if I click cancel and then print it's appear, how can I solve that to print the background image from first click? CSS Code:
<style>
@@media print {
.noprint {
display: none;
}
body::before {
content: "";
background: url(/Areas/Adam/Content/bc.png);
opacity: 0.09;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: 9999;
background-position: center;
-webkit-print-color-adjust: exact !important;
}
body {
-webkit-print-color-adjust: exact !important;
position: relative;
margin: 0;
}
* {
-webkit-print-color-adjust: exact !important; /* Chrome, Safari, Edge */
color-adjust: exact !important; /*Firefox*/
}
}
@@page {
-webkit-print-color-adjust: exact !important;
}
Element:
<div class="floating-button noprint">
<button class="btn btn-primary noprint" id="pdf" onclick="window.print();return false;">PDF</button>