Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mohammadkhallaf's avatar

print one page only

i use this button and this script to print report with many pages but it print only one page

<button onclick="printpage();" id="printpagebutton" class="print-button" type="button"> <span class="print-icon"> </button>

<script>
     function printpage() {
        //Get the print button and put it into a variable
        var printButton = document.getElementById("printpagebutton");
        //Set the print button visibility to 'hidden'
        printButton.style.visibility = 'hidden';
        //Print the page content
        window.print()
        printButton.style.visibility = 'visible';
    }
</script>
0 likes
1 reply
bestmomo's avatar

Hello

window.print() prints only the current page.

Please or to participate in this conversation.