Pdfmake: Footers and headlines on the pdf page

Created on 10 Mar 2014  路  5Comments  路  Source: bpampuch/pdfmake

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

feature request

Most helpful comment

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]
    };
},

All 5 comments

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?

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]
    };
},

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

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

How can we add line seperator in footer in datatable

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kamilkp picture kamilkp  路  3Comments

imoum007 picture imoum007  路  3Comments

SummerSonnet picture SummerSonnet  路  3Comments

kumarandena picture kumarandena  路  3Comments

davidyeiser picture davidyeiser  路  3Comments