Datatables - Change Font Size of Printed Page Title

Viewed 8480

I have a problem when attempting to change my printed page title's font. I've used the customize method based on this documentation

and here's my code:

$(document).ready(function() {
$('#tabelservis').DataTable( {
    "columnDefs": [
            { "type": "numeric-comma", targets: [0, 3] }
    ],
    dom: 'Bfrtip',
    buttons: [
        {
            extend: 'copyHtml5',
            exportOptions: {
                columns: [ 0, ':visible' ]
            }
        },
        {
            extend: 'excel',
            exportOptions: {
                columns: [ 0,1, 2, 3, 4 ]
            }
        },
        {
            extend: 'print',
            title: 'All of Services',
            exportOptions: {
                columns: [ 0,1, 2, 3, 4 ]
            },
            customize: function ( win ) {
                $(win.document.body)
                    .css( 'font-size', '12px' );

                $(win.document.body).find( 'table' )
                    .css( 'font-size', '12px' );
            }

        }
    ]
} );
} );

But still the title font is not changing, here's the screenshot:

enter image description here

As you can see, the big "All of services" still has big font size.

Any suggestions to solve this? Thank you

3 Answers

Try wrapping your title in a div with style setting the font size:-

buttons [
 extend: 'print',
 title: function() {
    return "<div style='font-size: 14px;'>My Title</div>";
  } 

]
Related