как добавить скрипт pdfmake в datatable - PullRequest
0 голосов
/ 03 июля 2018

Я пытаюсь работать с функцией экспорта в DataTables, теперь мое текущее требование - экспортировать пользовательский PDF-файл (изменить размер шрифта, цвет и т. Д.). В документации DataTable говорится, что мы можем интегрировать ее с PDFmake, что я не могу сделать. Таким образом, мой вопрос,

как применить это к datatable при экспорте pdfmake?

var dd = {
content: [
    {
        text: 'This paragraph uses header style and extends the alignment property',
        style: 'header',
        alignment: 'center'
    },
    {
        text: [
            'This paragraph uses header style and overrides bold value setting it back to false.\n',
            'Header style in this example sets alignment to justify, so this paragraph should be rendered \n',
            'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Malit profecta versatur nomine ocurreret multavit, officiis viveremus aeternum superstitio suspicor alia nostram, quando nostros congressus susceperant concederetur leguntur iam, vigiliae democritea tantopere causae, atilii plerumque ipsas potitur pertineant multis rem quaeri pro, legendum didicisse credere ex maluisset per videtis. Cur discordans praetereat aliae ruinae dirigentur orestem eodem, praetermittenda divinum. Collegisti, deteriora malint loquuntur officii cotidie finitas referri doleamus ambigua acute. Adhaesiones ratione beate arbitraretur detractis perdiscere, constituant hostis polyaeno. Diu concederetur.'
            ],
        style: 'header',
        bold: false
    }
],
styles: {
    header: {
        fontSize: 18,
        bold: true,
        alignment: 'justify'
    }
}
}

это мой сценарий с данными:

$(document).ready(function() {
        $('#globaldatatable').DataTable({
                scrollX: '100%',
                scrollY: 400,
                iDisplayLength: '100',
            ordering: false,
            bPaginate: false,
            sDom: '<"row"<"col-sm-6"B><"col-sm-6">>' + '<"row"<"col-sm-12"<"table-responsive"t>>>' + '<"row"<"col-sm-5"><"col-sm-7">>',
            buttons: {
                buttons: [
                    {   extend: 'pdfHtml5',
                        text: '<i class="fa fa-file-pdf-o"></i> PDF',
                        className: 'excelButton',
                        orientation: 'landscape',
                        title: 'Laporan Detail Karyawan',
                        pageSize: 'A4'
                    },
                    {   extend: 'excelHtml5',
                        text: '<i class="fa fa-file-excel-o"></i> EXCEL',
                        className: 'excelButton',
                        title: 'Laporan Detail Karyawan',
                        message: $('#printed').text()
                    }],
                dom: {
                    container: {
                        className: 'dt-buttons'
                    },
                    button: {
                        className: 'btn btn-default'
                    }
                }
            },
            "columnDefs": [ { "width": "5%", "targets": 0 } ]
        });
    });
...