KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Print page does not match #2427

Closed saiful opened this topic on on Nov 11, 2021 - 2 comments

saiful commented on Nov 11, 2021

im using datatables for my report, and enable print button on it, but the page that i print doesn't match with my report page. what should i do? here is the screenshot of my report:

this is my print result:

i want my printed report result has same layout & color

saiful commented on Nov 11, 2021

im using both print option like this:

"options"=>array(
                  "paging"=>false,
                  "searching"=>false,
                  "dom" => 'Bfrtip',
                  "buttons" => [
                      "excel", "print"                  // it has same result
                  ],
                  "buttons" => [                        // with this option
                    "excel",
                    [
                        "extend" => "print",
                        "customize" => "function(win)
                        {
             
                            var last = null;
                            var current = null;
                            var bod = [];
             
                            var css = '@page { size: portrait; }',
                                head = win.document.head || win.document.getElementsByTagName('head')[0],
                                style = win.document.createElement('style');
             
                            style.type = 'text/css';
                            style.media = 'print';
             
                            if (style.styleSheet)
                            {
                              style.styleSheet.cssText = css;
                            }
                            else
                            {
                              style.appendChild(win.document.createTextNode(css));
                            }
             
                            head.appendChild(style);
                     }"
                 ],
            ] 
            ),
Sebastian Morales commented on Nov 12, 2021

DataTables' Print button is a client-side solution that only print the table with their own style, not the whole report with user's custom style. If you want to print the report exactly like it looks pls use our Export or CloudExport package which uses a headless browser to render the whole page to pdf like what you see on browser:

https://www.koolreport.com/docs/export/get_started/

https://www.koolreport.com/docs/cloudexport/chromeheadlessio/

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

DataGrid