How to add the page number at every page of the print when printing data?

How to add the page number at every page of the print when printing data?

MudassirAmeenMudassirAmeen Posts: 1Questions: 1Answers: 0

Hey, i need your help. i am using datatables and it is very handy when i print the data. now my client ask me to print the page number in the footer of every page with custom css. the default footer of print is not good. so i need to display it the footer of every page. not in footer but at the end of every page. the page numbers should be like this.
Page 1 of 20
Page 2 of 20
...
Page 20 of 20
i have searched everything but nothing solved my problem. if you can solve this so please answer to this question. Thanks

Answers

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin

    As far as I am aware there is no option for that in HTML.

    This SO thread might have a possibility, but you'd need to use the customize callback for the print button to modify the document, and I think that might be very difficult with a table.

    Allan

  • o4osmano4osman Posts: 1Questions: 0Answers: 0
    @page {
        font-family: "Fira Mono";
        font-size: 12px;
        sheet-size: A4;
    
    
        @bottom-left {
            content: 'Page ' counter(page) ' of ' counter(pages);
            border-top: 1px solid #000;
            margin-bottom: 15px;
        }
        @bottom-center {
            content: 'Printed on: {{ \Carbon\Carbon::now()->format('M d, Y') }}';
            border-top: 1px solid #000;
            margin-bottom: 15px;
        }
    
        @bottom-right {
            content: 'Printed by Business Book';
            border-top: 1px solid #000;
            margin-bottom: 15px;
        }
    }
    

    I also tried everything nothing worked except this code. I hope it helps.(you can change font and other setting according to your choice).

Sign In or Register to comment.