Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

not display footer with header #2269

Closed
Neurotec opened this issue Mar 29, 2015 · 3 comments
Closed

not display footer with header #2269

Neurotec opened this issue Mar 29, 2015 · 3 comments

Comments

@Neurotec
Copy link

hi, the footer it's not display when exists the same script source..
i do test and found something.
tested with

  • wkhtmltopdf 0.12.2.1 (with patched qt)
  • wkhtmltopdf 0.12.3-dev-3b4f21b (with patched qt)

test: this works' ok, show footer and header.
test.raw.html

<!DOCTYPE html>
<html>
    <head>
        <script>
        function subst() {
            var vars={};
            var x=window.location.search.substring(1).split('&');
            for (var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
            var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
            for (var i in x) {
                var y = document.getElementsByClassName(x[i]);
                for (var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
            }
        }
        </script>
    </head>
    <body style="border:0; margin: 0;" onload="subst()">
        <h1>TEST</h1>
        <table style="border-bottom: 1px solid black; width: 100%">
            <tr>
                <td class="section"></td>
                <td style="text-align:right">
                    Page <span class="page"></span> of <span class="topage"></span>
                </td>
            </tr>
        </table>
    </body>
</html>
wkhtmltopdf --footer-html test.raw.html --header-html test.raw.html www.startpage.com output.pdf

test: now this not work, display header but not footer, i extract javascript and put a external file.
test.jsexternal.html

<!DOCTYPE html>
<html>
    <head>
        <script src="http://localhost/subst.js"></script>
    </head>
    <body style="border:0; margin: 0;" onload="subst()">
        <h1>TEST</h1>
        <table style="border-bottom: 1px solid black; width: 100%">
            <tr>
                <td class="section"></td>
                <td style="text-align:right">
                    Page <span class="page"></span> of <span class="topage"></span>
                </td>
            </tr>
        </table>
    </body>
</html>
wkhtmltopdf --footer-html test.jsexternal.html --header-html test.jsexternal.html www.startpage.com output.pdf

test: and if i copy script/javascript and rename it, it works again display footer and header. !!looks script tag
test.jsexternal.html

<!DOCTYPE html>
<html>
    <head>
        <script src="http://localhost/subst.js"></script>
    </head>
    <body style="border:0; margin: 0;" onload="subst()">
        <h1>TEST</h1>
        <table style="border-bottom: 1px solid black; width: 100%">
            <tr>
                <td class="section"></td>
                <td style="text-align:right">
                    Page <span class="page"></span> of <span class="topage"></span>
                </td>
            </tr>
        </table>
    </body>
</html>

test.jsexternal2.html

<!DOCTYPE html>
<html>
    <head>
        <script src="http://localhost/subst2.js"></script>
    </head>
    <body style="border:0; margin: 0;" onload="subst()">
        <h1>TEST</h1>
        <table style="border-bottom: 1px solid black; width: 100%">
            <tr>
                <td class="section"></td>
                <td style="text-align:right">
                    Page <span class="page"></span> of <span class="topage"></span>
                </td>
            </tr>
        </table>
    </body>
</html>
wkhtmltopdf --footer-html test.jsexternal2.html --header-html test.jsexternal.html www.startpage.com output.pdf

sorry, my english

@ghost
Copy link

ghost commented Apr 21, 2015

wkhtmltopdf --footer-html test.jsexternal2.html --header-html test.jsexternal.html www.startpage.com output.pdf

when you finished this cmd, did you get correct page number on your footer?

@ashkulz
Copy link
Member

ashkulz commented Jun 23, 2015

Thanks for the detailed test case, I had to recreate it from scratch in #2183. It will be fixed in a few hours.

@ashkulz
Copy link
Member

ashkulz commented Jul 14, 2015

A preview for the next release 0.12.3-dev-79ff51e is available, which should contain the fix for this issue. Please report back if it is not solved with the above version.

Please note that the above downloads will be removed after the 0.12.3 release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants