PDF Export function.
PDF Export function.
usaman45
Posts: 6Questions: 4Answers: 0
I have code but not sure how to add PDF export function and with different name, please help.
Here is my code:
<script>
var today = new Date();
var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date + '_' + time;
$(document).ready(function () {
gridDataTableView("UsersList.xls");
});
gridDataTableView = function (fname) {
$('#tblGrid').dataTable({
"bFilter": true,
"bLengthChange": false, "bPaginate": true, "bInfo": true,
dom: 'Bfrtip',
"order": [[0, 'desc'], [1, 'desc']],
buttons: [{ extend: 'copy', text: 'Copy to clipboard', className: 'copyButton' },
{ extend: 'excelHtml5', text: 'Export to Excel file', className: 'link_button', title: fname }]
});
}
</script>
EDIT: Updated post to format code using Markdown formatting.
This discussion has been closed.
Answers
Does this doc answer your questions?
https://datatables.net/reference/button/pdfHtml5
Kevin
I added pdf part to code but the PDF button is not showing.
$('#tblGrid').dataTable({
"bFilter": true,
"bLengthChange": false, "bPaginate": true, "bInfo": true,
dom: 'Bfrtip',
"order": [[0, 'desc'], [1, 'desc']],
buttons: [{ extend: 'copy', text: 'Copy to clipboard', className: 'copyButton' },
{
extend: 'pdfHtml5',
text: 'Save current page',
exportOptions: {
modifier: {
page: 'current'
}
}
},
{ extend: 'excelHtml5', text: 'Export to Excel file', className: 'link_button', title: fname }]
});
Did you include the PDFMake library as mentioned in the do clink?
You can use the Download Builder to generate all the required files for your solution.
Kevin