TJkrusinski / NodePDF

Down and dirty PDF rendering in Node.js with PhantomJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with the header and footer options

cpchan718 opened this issue · comments

Hi,

I am having an issue with the header and footer option. When I place an attribute into a html tag like style='some css'. The header and footer does not show. I think there is an issue with the quotations within quotations. Like so:

'header': {
                    'height': '1cm',
                    'contents': "<span style='text-align:center'><small>" + titleheader + "</small></span>"
},
'footer': {
                    'height': '1cm',
                    'contents': '<span style="text-align:right"><small>{currentPage}</small></span>'
}

Thou, it does work without the attributes. Like so:

'header': {
                    'height': '1cm',
                    'contents': "<center><small>" + titleheader + "</small></center>" 
},
'footer': {
                    'height': '1cm',
                    'contents': '<span><center><small>{currentPage}</small></center></span>'
}

It will be great if I can align the footer page numbers to the right of the PDF.

Thanks!

Would also love it if this was more flexible

Could you please try:

'contents': '<span style="text-align:center"><small>' + titleheader + '</small></span>'

That's what I've been trying in my implementation, but to no avail.

Interesting. Sorry then I have to debug a little bit more. Header and footer stuff was quite tricky but I'm sure it works in some of my projects. Could you also try to set another property like background-color instead of text-align center, maybe something with the viewport is wrong. And in general header and footer are like own pages, so it should include html and body tags.

Seems to choke whenever a tag has any properties. So all of these cause it to hang:

contents: '<div class="test">content</div>'
contents: '<div class=test>content</div>'
contents: "<div class='test'>content</div>"

however

contents: '<div>content</div>'

works fine