Pdfmake: How to know the height of the header

Created on 19 Mar 2018  路  3Comments  路  Source: bpampuch/pdfmake

I created a pdf that the header height is dynamic and I want to put the margin of the content page according to that header height. Is there a way to get the header height that is created ? The header will change according to the information that the user will put. So I can't predict how much the height will be.

If you have any question, don't be shy to ask.

Thank you.

Most helpful comment

@dudusotero I believe that @MathLavallee wanted to say, that he has dynamic content that is printed on the header, like different number of text rows, etc. So he can't put fixed value in the pageMargins because if text is too large it will be truncated.
I have the same issue, is any way to know the height of any rendered pdf document. I am ready to pre-render the header alone, get its height, then create the whole document with pageMargins calculated from the pre-rendered header.

Thanks.

PS: @MathLavallee how did you resolved this issue?

All 3 comments

The height of the header is the same as the top margin of the page, so I believe that changing the margin value would already solve your problem regarding the dynamic height of the header.

In this example, to change the height of the header dynamically, change the value of the variable _top_.

var top = 80;
var dd = {
    pageMargins: [40, top, 40, 40],
    header: function(currentPage) {
        return [
            { text: 'Header' }
        ]
    },
    content: [
        { text: 'Some text here...' }
    ],
};

@dudusotero I believe that @MathLavallee wanted to say, that he has dynamic content that is printed on the header, like different number of text rows, etc. So he can't put fixed value in the pageMargins because if text is too large it will be truncated.
I have the same issue, is any way to know the height of any rendered pdf document. I am ready to pre-render the header alone, get its height, then create the whole document with pageMargins calculated from the pre-rendered header.

Thanks.

PS: @MathLavallee how did you resolved this issue?

I would love pageMargins to accept a function, like header and footer, so I can change margins per page.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sayjeyhi picture sayjeyhi  路  3Comments

svenyonson picture svenyonson  路  3Comments

jokris1 picture jokris1  路  3Comments

SummerSonnet picture SummerSonnet  路  3Comments

kumarandena picture kumarandena  路  3Comments