DataTables / DataTablesSrc

DataTables source repository
https://datatables.net
MIT License
587 stars 422 forks source link

Feature suggestion: allow adding pagedJs to the print view #276

Open petermorlion opened 2 months ago

petermorlion commented 2 months ago

I know several/many people have been looking to add page numbers to the print result of the "print" button. For the PDF button, this is possible with the following code:

doc.footer = function (currentPage, pageCount) {
    return [
        { 
            text: translations.page + ' ' + currentPage.toString() + ' ' + translations.of + ' ' + pageCount,
            width: '*',
            alignment: 'center'
        }
    ];
};

For the print button, it's not so simple. However, I believe it would be possible if we could add paged.js to the resulting HTML. I've tried adding it in the customize function, but that doesn't work. I assume because it's added after the page has been opened in the browser already, so the paged.js script isn't executed.

Would you consider allowing such a thing? If so how? An option like addPagedJs may be too hard-coupled to that implementation. Maybe something like customScripts which could be an array of scripts URLs that are added to the print page?

AllanJard commented 2 months ago

It is certainly something that I'll consider. A customScripts option might be a good idea - thanks for the suggestion. I'm not yet sure when I'll be able to get to it, but yes, it is something that it would be nice to see.

petermorlion commented 2 months ago

I created a pull request in the correct repo.