Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datatables - Change Font Size of Printed Page Title

Tags:

css

datatables

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

like image 429
apripuppey Avatar asked Dec 19 '22 05:12

apripuppey


2 Answers

The title is on <h1> html markers. So You can change all css style for this marker.

For example:

 customize: function ( doc ) {
     $(doc.document.body).find('h1').css('font-size', '15pt');
     $(doc.document.body).find('h1').css('text-align', 'center'); 
 }

Etc. ;)

like image 149
Brudka Avatar answered Dec 26 '22 19:12

Brudka


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>";
  } 

]
like image 45
Grebe.123 Avatar answered Dec 26 '22 18:12

Grebe.123