Need The Table formatted pdf with borders

Need The Table formatted pdf with borders

raja424raja424 Posts: 12Questions: 1Answers: 0

Hi
the export to pdf is working as good but i need to display borders to table in pdf .
The below is code, can anyone help me on the same

<

script type="text/javascript">

// The below is working as expected
$(document).ready(function () {
var count = $('#example1').val();

    var t = $('#example1').DataTable({           
        dom: 'Blfrtip',
        buttons: [
            {
                extend: 'excelHtml5',


                text: 'Export to Excel',                                       
                exportOptions: {

                    columns: [0, 1, 2, 3, 4]
                }
            },

            {
                extend: 'pdfHtml5',
                //download: 'open',                 

                text: 'Export to PDF',
                //customize: function(doc) {
                //    //pageMargins [left, top, right, bottom] 
                //    doc.pageMargins = [ 50, 50, 50, 200,];
                //},

                customize: function (doc) {
                    doc.content.forEach(function (item) {                           
                        if (item.table) {
                            // Set width for 3 columns
                            doc.pageMargins = [50, 50, 50, 200, ]; 
                           // item.table.customize.css('');
                            doc.styles.title = {
                                //color: 'red',
                                //fontSize: '15',
                                //background: 'blue',
                                alignment: 'center'
                            }
                            //doc.styles= {
                            //    color: 'none',                                                                    
                            //    alignment: 'center'                                   
                            //}                               
                            //doc.fromHTML($('#target').html(), 15, 15, {
                            //    'width': 170, 'elementHandlers': specialElementHandlers
                            //});
                        }                           
                    });

                },                    
                exportOptions: {                                     
                    columns: [0, 1, 2, 3, 4]
                },

            }

        ],
        fnDrawCallback: function (oSettings) {
            var that = this;
            if (oSettings.bSorted || oSettings.bFiltered) {
                this.$('td:first-child', { "filter": "applied" }).each(function (i) {
                    that.fnUpdate(i + 1, this.parentNode, 0, false, false);
                });
            }
        },
        "aoColumnDefs": [
        { "bSortable": false, "aTargets": [0, 5] }, {}
        ],

    });
 //   debugger;
    $("#example1").on('DOMNodeInserted DOMNodeRemoved', function () {
        if ($(this).find('tbody tr td').first().attr('colspan')) {
            $(".dt-buttons").css('display', 'none');
            $(this).dataTable.Buttons.background = 'none';
            // return "There is no matching records";
        } else {
            $(".dt-buttons").css('display', 'inline');
        }
    });

    //this shows the dataTable (simplified)
    //dataTable.fnAddData(
    //    ['a', 'b', 'c', 'd', 'e']
    //);
    //this hides it (assuming there is only one row)
    //dataTable.fnDeleteRow(0);

    // testeing for pdf lines             

    // testeing ends for pdf lines
});

Replies

  • allanallan Posts: 63,099Questions: 1Answers: 10,391 Site admin

    You'll need to refer to the pdfmake documentation for details on how to use that libraries APIs to add borders to cells.

    Allan

  • raja424raja424 Posts: 12Questions: 1Answers: 0

    Thanks for info.. But I am not able to find borders in table section of pdfmake

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    You will need to ask the pdfmake people for information about pdfmake.

This discussion has been closed.