pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Footers and headlines on the pdf page

Open przemo22 opened this issue 12 years ago • 5 comments

As in the topic, I want to know if there is a possibility of adding a header/footer on each page?

przemo22 avatar Mar 10 '14 09:03 przemo22

First, basic question: How can I add footer and header in pdf? I try by passing below code, but didn't work

{ header: { text : "valueOfHeader" }, footer: { text: "valueOfFooter" } }

Second question: how can i insert page numbers in footer?

przemo22 avatar Mar 24 '14 09:03 przemo22

Your sample is working fine, just remember to define content as well as it's mandatory.

Alternatively header and footer can be set to a function taking two arguments (currentPage, pageCount)

For a simple case the following piece of code should be enough:

footer: function(page, pages){ return page + ' of ' + pages; },

Remember the function can return any valid node (if a simple text is not enough), so a more complex example could look like this:

footer: function(page, pages) { 
    return { 
        columns: [ 
            'Left part of footer',
            { 
                alignment: 'right',
                text: [
                    { text: page.toString(), italics: true },
                    ' of ',
                    { text: pages.toString(), italics: true }
                ]
            }
        ],
        margin: [10, 0]
    };
},

bpampuch avatar Mar 24 '14 18:03 bpampuch

Thank's a lot, now it works well :+1:

przemo22 avatar Mar 25 '14 06:03 przemo22

dynamic footer footer: function(page, pages){ return page + ' of ' + pages; } is not working in webworker

rizwanspeaks avatar Feb 02 '16 08:02 rizwanspeaks

How can we add line seperator in footer in datatable

nilakshibhosale avatar Feb 01 '19 12:02 nilakshibhosale