0

I have problem with setting margins for PDF exported document. I've tried a lot of things and settings, but no hope. The ones that are interested in helping and solving this problem can check this links: https://jsfiddle.net/ivans_software/hn2gcken/20/ http://live.datatables.net/poqoyezo/24/

    $('#example').DataTable({
    dom: 'Bfrtpi',
    buttons: [
        // 'colvis', // custom columns include JS    https://cdn.datatables.net/buttons/1.0.1/js/buttons.colVis.min.js
        // 'colvisRestore', // restore default columns include JS https://cdn.datatables.net/buttons/1.0.1/js/buttons.colVis.min.js
        'pdf', { // default PDF and customized PDF
     extend: 'pdfHtml5',
     title: 'Random Persons', // report header/title
     orientation: 'landscape',
     pageSize: 'A4',
     pageMargins: [ 0, 0, 0, 0 ], // try #1 setting margins
     margin: [ 0, 0, 0, 0 ], // try #2 setting margins
     text: '<u>E</u>xport Page (PDF)',
     key: { // press E for export PDF
         key: 'e',
         altKey: false
     }
     , content: [{ style: 'fullWidth' }]
         , styles: { // style for printing PDF body
                    fullWidth: { fontSize: 18, bold: true, alignment: 'right', margin: [0,0,0,0] }
         },
     download: 'download',
     exportOptions: {
         modifier: {
                     pageMargins: [ 0, 0, 0, 0 ], // try #3 setting margins
                 margin: [ 0, 0, 0, 0 ], // try #4 setting margins
             alignment: 'center'
         }
         , body : {margin: [ 0, 0, 0, 0 ], pageMargins: [ 0, 0, 0, 0 ]} // try #5 setting margins         
         , columns: [0,1] //column id visible in PDF    
         , columnGap: 1 // optional space between columns
     }
 }],
    columns: [
        {
            title: 'Person name',
            defaultContent: '', // if no content set in field
            data: 'name'
        },
        {
            title: 'Person age',
            type: 'num', // this would be a number field
            data: 'age'
        }
    ],
    data: [
        {name: 'John Doe', age: 25},
        {name: 'Michael Jackson', age: 30},
        {name: 'Tom Jones', age: 32},
        {name: 'Monica Beluchi', age: 34}
    ]
});

the first link is more described than the second, but the point is the same...

IvanS
  • 1
  • 1
  • 2
  • Can you please shorten your code to a minimal example that still has the problem? There is a lot of code that has nothing to do with the problem at hand, and it is easier for others to debug when there is a minimal example. – mprat Mar 10 '16 at 15:52

0 Answers0