add styles for PDF files that are downloaded by JQUERY DATATABLES

1

I have a problem generating a PDF file with the library Jquery Datatable , when generating the pdf I download by default the blue color in the header of the table, but my company handles the color red, I leave the code javascript with which I generate the PDF download

      var table = $("#data_list_consecutivos").DataTable({
            ordering: true
        });

        new $.fn.dataTable.Buttons( table, {
            buttons: [
                {
                    extend: 'pdfHtml5',
                    text: 'Abrir en PDF',
                    download: 'open',
                    className: 'btn-danger',
                    messageTop: 'Pedidos de Concentrados Tramitados',
                    title:'Intranet  Cercafe',
                    exportOptions: {
                        columns: [ 0, 1, 2, 3, 4, 5, 6]
                    },
                    customize:function(doc) {
                        doc.styles.title = {
                            color: 'red',
                            fontSize: '40',
                            alignment: 'center'
                        }
                        doc.styles['td:nth-child(2)'] = { 
                            width: '100px',
                            'max-width': '100px'
                        }
                    }
                },
            ],
        });

        table.buttons( 0, null ).container().appendTo(
            table.table().container()
        );

to leave it as this generates me this PDF

but when I add this line of code in javascript it generates this

                        doc.styles.tableHeader = {
                            background: '#DF0101',
                            color:'white'
                        }

I would appreciate it if you would help me with this

    
asked by Juan Esteban Yarce 04.05.2018 в 21:31
source

1 answer

0

It is because you put a background and that is not the property to occupy, your code should be like this:

doc.styles.tableHeader = {
  fillColor:'#DF0101',
  color:'white'
}

Using fillColor resolves, greetings.

    
answered by 30.06.2018 в 14:26