How can I put a line and space in the PDF header?

How can I put a line and space in the PDF header?

otavio_laskosk_pcotavio_laskosk_pc Posts: 21Questions: 6Answers: 0
edited February 2021 in Free community support

I put this header and I don't manage add a line and space to separate from grid.

source:

    var tabExp = $('#tabelaDataTableExport').DataTable({
        //dom: '<Bf<t>ip>',

        dom: "<'row'<'col-sm-6'B><'col-sm-6'f>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-6'i><'col-sm-6'p>>",
        buttons: [ 

            {
                
                customize: function ( doc ) {

  doc['header']=(function(page, pages) {
                        return {
                            columns: [
                                
                            {
                                alignment: 'left',
                        image: 'logo.jpg',
                        width: 100
                        
                                /*text: [
                                    { text: page.toString(), italics: true },
                                    ' / ',
                                    { text: pages.toString(), italics: true }
                                ]*/
                            },
                            {
                                bold: true,
                                fontsize:'100px',
                                text:'Rlatório de Previsões',
                                alignment: 'center',
                                margin:[80,10,0,]
                                
                            },
                            {
                                
                                text: [
                                    { text: page.toString(), italics: true },
                                    ' / ',
                                    { text: pages.toString(), italics: true }
                                ],
                                
                                alignment: 'right',
                                margin:[100,10,0]
                            }

                            
                            
                            ],
                            alignment: 'center',
                            margin: [60, 18,80,100]


                           
                        };
                    });
                    
                    
              },
            }
        ],

        language: {
            url: uri_arquivo
        }

        //order: [[ 0, "asc" ]]
    });

Anyone know how do it?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    And finally if you go the pdfmake site, on the margin page it shows how to add a margin to the header (this will push down the table data as you want).

    Cheers,

    Colin

  • otavio_laskosk_pcotavio_laskosk_pc Posts: 21Questions: 6Answers: 0

    Hi Colin,

    Thank you by your reply.

    According the tutorial you've passed, It works by a text and style. I can't apply it in the funtion doc['header'] in the customize: function ( doc ).

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    doc['header'] in the customize: function ( doc ).

    Why not? The customize callback is just a callback function that will let you modify the pdfmake document description that the pdf button creates. All formatting is done by pdfmake itself, so if you want to customise the output, you'd need to modify the document structure.

    Allan

  • otavio_laskosk_pcotavio_laskosk_pc Posts: 21Questions: 6Answers: 0

    Hi Allan,

    Thank you by your reply.

    I've tried to add the command margin: [0, 0,0,80] in the function margin: [60, 18,80,100,80] according the tutorial but it hasn't worked.

  • otavio_laskosk_pcotavio_laskosk_pc Posts: 21Questions: 6Answers: 0
    edited May 2018

    Follow the source I'm using.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I couldn't get the margin to work with the title, no idea why, since it should be fine. However, you can fudge it like the example here

    Cheers,

    Colin

This discussion has been closed.