Custom Header/Footer sizes for phantompdf template.

  • Custom Header/Footer sizes for phantompdf template.

    Note: Thanks for an awesome product. Just picked up 2 single server licenses and I really like the product.

    If I change the size of the headers/footers to show more than 1 line it also moves the header/footers up and down the page. ie. Add 3 line header and change header size to 3cm to show all the text. Headers are now shown but they also moved 3cm down the page and there is now a large amount of blank space above the header. This works exactly the same for footers.

    I have a template that requires large multi-line static headers/footers. I added "child" templates (this works the same if I add the content directly to the header/footers in the phantompdf menu) but when I change the size attribute it moves the header/footers up/down the page instead of just showing more.

    Is there a configuration option or some attribute i'm missing? I don't fiddle with the margins or anything else. Here is a jsreport playground with the above issue. Header Footer Playground

  • Just to make sure I understand...
    The problem is that with bigger header, phantomjs always put some blank space at the top - even before the header, right?

  • Yes. There is normally blank space. Here are some pictures to show. The first is the default 1cm header. It only shows 1 line of text even though I have 5 lines in the header. The 2nd is a 5cm header. It now shows all the text but as you can see it also moved 5cm down the page making the white space huge and the header un-usable. The only difference in pics are the settings. 1cm header vs 5cm header. The content of the header was identical.

  • It is expected that the content won't fit if you set only 1cm header. phantomjs is not doing any adaptation here and the height is fixed number. You need to set the number bigger than the actual header content height. It won't work well with dynamic header heights on different pages.

    The gap at the top which grows with bigger header height is likely phantomjs/webkit/qt bug. Unfortunately it is currently not in our power to do fixes there.
    However I'll try to search if there is a workaround.

  • I assumed the header size had to be bigger to fit the larger header. I did not expect the header to move down the page. I figured it was a bug of some kind with phantomjs. Please let me know if you find a workaround.

    Thanks for your help.

  • @bjrmatos Found a workaround for you.

    1. You need to install latest jsreport-phantom-pdf package
    npm install jsreport-phantom-pdf@1.4.2
    1. Then refresh studio and set the margin as this
    { "top": "0px", "left": "50px", "bottom": "50px", "right": "50px" }
    1. Note this is required only when running on windows os. You should not see the gap bug when running on linux

    See the link to the PR adding the complex margin settings

    Please let us know if this fixes your problem.

  • Thanks Jan! Ill give it a try and report back.

  • Hey Jan! I gave your solution a try and cant get it to work. It may be due to my inexperience with node server. These are the steps I took to try and fix the issue.

    1. Close node.js command prompt (it was running node server).
    2. Start node.js command prompt.
    3. Type in "npm install jsreport-phantom-pdf@1.4.2"
    4. Type in "npm start"
    5. Change the margin to the { "top": "0px", "left": "50px", "bottom": "50px", "right": "50px" } under phantompdf margin as shown in

    I also tried completely rebooting the computer after installing the latest version of phantom-pdf.

    My question is weather or not I need to tell jsreport that it needs to use the latest version of phantom-pdf or does that happen automatically when I run the npm install jsreport-phantom-pdf@1.4.2.

    Sorry for the confusion on the licenses stuff. We thought the 2 servers would be enough but after more meetings we realized the enterprise unlimited was what we need.

  • Hmm, it should work, see the following screen.
    You just need to stop the running jsreport, do the mentioned install and start it again.


    We will release in couple of minutes full jsreport distribution 1.6.0, so you may try full install.

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.