Estoy tratando de agregar el número de página en la exportación de datatble pdf, obtuve el código de su sitio oficial después de agregar este botón de código pdf desapareció y aparece el error ' Uncaught ReferenceError: doc no está definido en HTMLDocument' en la consola.
$('#table2').DataTable({ dom: 'Bfrtip', buttons: [ { extend: 'pdfHtml5', title: 'Data export', filename: 'dt_custom_pdf', pageSize: 'A4', exportOptions: { columns: ':visible', search: 'applied', order: 'applied' }, }, doc['footer']=(function(page, pages) { return { columns: [ 'Left part of footer', { alignment: 'right', text: [ { text: page.toString(), italics: true }, ' of ', { text: pages.toString(), italics: true } ] } ], margin: [10, 0] } }); ] });No definió la función de personalización en la tabla de datos, por eso necesita cambiar el error de documento.
$('#table2').DataTable({ dom: 'Bfrtip', buttons: [ { extend: 'pdfHtml5', text: 'Pdf', filename: 'dt_custom_pdf', pageSize: 'A4', exportOptions: { columns: ':visible', search: 'applied', order: 'applied' }, customize: function ( doc ) { doc['footer']=(function(page, pages) { return { columns: [ { alignment: 'center', text: [ { text: page.toString(), italics: true }, ' of ', { text: pages.toString(), italics: true } ] } ], margin: [10, 0] } }); } } ] });