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

v0.12.2.1 and 0.12.1 - Page headers given in --header-html only shown in the first page of PDF file #2284

Open
faustow opened this issue Apr 7, 2015 · 6 comments

Comments

@faustow
Copy link

faustow commented Apr 7, 2015

(This issue was first introduced in #2098.)
Using the --header-html parameter will only make the headers show in the first page of the pdf. This didn't happen in v0.12.1.

The HTML used is

<div id="client-non-compliant-player-list">
    <table>
        <th>THIS IS THE TITLE</th>
    </table>
    <br>
    <table id="clients">
        <tr data-before-template='data-before-template'>
            <th class="client-column">CLIENT</th>
            <th class="team-column-header">TEAM</th>
            <th class="id-column">PLAYER ID</th>
            <th class="description-column">DESCRIPTION</th>
            <th class="inspection-column">INSPECTION</th>
            <th class="schedule-column">SCHEDULE</th>
        </tr>
        <tr data-template='data-template'>
            <td class="client-column">{{name}}</td>
            <td colspan="5">
                <table class="no-border">
                    <tr data-template-for='teams'>
                        <td class="team-column no-border">{{team_name}}</td>
                        <td class="no-border">
                            <table class='player-table no-border' >
                                <tr data-template-for="players" >
                                    <td class="id-column no-border">{{player_name}}</td>
                                    <td class="description-column no-border">{{player_description}}</td>
                                    <td class="inspection-column no-border">{{player_inspection}}</td>
                                    <td class="schedule-column no-border">{{player_schedule}}</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>

The {{...}}-labels are for tempojs.

The HTML used for the header (minus the js and css) is:

<div id="header">

        <table id='header-table'>
            <tr>
                <td class='td-contact'>
                    <span id='name'></span><br>
                    <span id='contact'></span>
                </td>
                <td class='td-image'>
                    <img
                        id='img-logo'
                        src=''
                        alt="Logo"
                    />
                </td>
                <td class='td-date'>
                    <span id='title'></span>
                    <br/>
                    <span id='title-date'>
                        Report Date
                    </span>
                    <span id='date'></span><br />
                    <span id='description'></span>
                </td>
            </tr>
        </table>
</div>
@ashkulz
Copy link
Member

ashkulz commented Apr 7, 2015

With

  • no header file
  • no command-line options
  • incomplete HTML

how do you expect an issue to be investigated? Please reopen the issue if you can provide a complete, self-contained HTML/CSS with complete command-line and environment details (OS, Language, 32/64-bit, etc).

@ashkulz ashkulz closed this as completed Apr 7, 2015
@ashkulz ashkulz added the Invalid label Apr 7, 2015
@faustow
Copy link
Author

faustow commented Apr 7, 2015

Hi @ashkulz :

  • The header file's HTML code is already in the description of the issue
  • Command line options are:
wkhtmltopdf --load-error-handling ignore --load-media-error-handling ignore --header-html "file://header.html" --footer-html "file://footer.html" --debug-javascript --javascript-delay 5000 --page-size Letter --orientation "Portrait" --margin-bottom 25mm --margin-top 40mm --header-spacing 3 "file://report_a.html" "report.pdf"

where header contains what I pasted in the description of the issue plus some css and js.

  • I pasted 'minimal' HTML as per your request on Big white space before nested table #2098 which is where this issue started: "posting the minimal HTML/CSS inline would be help in investigating this further" Do you need the complete file for header/footer/report? Not sure this would be helpful somehow since the page headers worked flawlessly on v0.12.1, nothing in the footer/header/report files was changed. I've only installed this newer version to try to avoid the Big white space before nested table #2098 issue, and now this other issue appears.

I am running Ubuntu 14.04 64 bits:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:  Ubuntu 14.04.1 LTS
Release:  14.04
Codename: trusty

$ uname -a
Linux lambda 3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

@faustow
Copy link
Author

faustow commented Apr 7, 2015

Pasting the complete header in case it helps:

<html>
<head>
<meta name="description" content="Header" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
#header{
    font-family: Arial, Helvetica, sans-serif;
}
#header td {
    background-color: #FFFFFF;
}
#header #header-table {
    width: 100%;
}
#header #name {
    font-style: italic;
    font-weight: bold;
}
#header #contact {
    font-size: 13px;
    line-height: 130%;
}
#header #title {
    font-size: 21px;
    font-weight:bold;
    margin-right: -1%;
}
#header #date {
    font-size: 18px;
}
#header #time {
    font-size: 18px;
}
#header #description {
    font-size: 13px;
    font-style: italic;
    line-height: 130%;
    text-align: right;
}
#header .td-contact {
    width: 43%;
    padding-left: 1%;
    padding-right: 1%;
    vertical-align: top;
}
#header .td-image {
    width: 14%;
    min-height: 45px;
    min-width: 100px;
    padding-left: 0.5%;
    padding-right: 0.5%;
    vertical-align: top;
}
#header .td-date {
    width: 43%;
    padding-right: 1%;
    padding-left: 1%;
    text-align: right;
    vertical-align: top;
}
#img-logo {
    max-height: 45px;
    max-width: 100px;
    margin: 10% auto 50% auto;
}
#title-date {
    font-size: 13px;
    padding-left:1%;
}
#span-date-time {
    font-size: 18px;
}
br {
   display: block;
   margin: 0 0;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://momentjs.com/downloads/moment.min.js"></script>
<script type="text/javascript">
// (removed the js used to fill in the date, contact info and so on)
</script>

</head>
<body onload='doDate(); doHeader(); doLogo();' style="margin: 0; padding: 0">
<div id="header">

        <table id='header-table'>
            <tr>
                <td class='td-contact'>
                    <span id='name'></span><br>
                    <span id='contact'></span>
                </td>
                <td class='td-image'>

                    <img
                        id='img-logo'
                        src=''
                        alt="Logo"
                    />
                </td>
                <td class='td-date'>
                    <span id='title'></span>
                    <br/>
                    <span id='title-date'>
                        Report Date
                    </span>
                    <span id='date'></span><br />
                    <span id='description'></span>
                </td>
            </tr>
        </table>
</div>
</body>
</html>

@ashkulz
Copy link
Member

ashkulz commented Apr 8, 2015

@faustow: please understand that I'm helping you out in my spare time. I should not have to hunt/guess for information which should be provided as per the support page.

  • In initial description, you provided just a snippet of your main page
  • Command-line uses header.html, footer.html and report-a.html -- where are they?
  • header.html has references to doDate and doHeader -- where are they?

Without something I can run, I cannot verify. Read up on how to report bugs effectively.

@faustow
Copy link
Author

faustow commented Apr 22, 2015

Hi @ashkulz :
Thanks a lot for your answer. I hope this message gives you enough information to be able to dig on this matter.
I spent the past few days hunting this bug too. I went about removing stuff and compiling again and again, and see which changes would seem to trigger this error in the headers of each page.

  • The call now looks as follows (notice I've removed many parameters)
wkhtmltopdf --header-html "file://header.html" --footer-html "file://footer.html" --page-size Letter --orientation "Portrait" --margin-bottom 25mm --margin-top 40mm "file://report_a.html" "report.pdf"
  • Header1.html - I've removed most of the header, it now looks as follows (this one works):
<!DOCTYPE html>
<html>
    THIS IS THE HEADER
</html>
  • Header2.html - This one does not work:
<!DOCTYPE html>
<html>
<script src="http://momentjs.com/downloads/moment.min.js"></script>
        THIS IS THE HEADER
</html>
  • Footer.html - This one has also been trimmed down to nearly nothing:
<!DOCTYPE html>
<html>
</html>
  • Report.html - Here's where the big code trimming took place. I've removed nearly all js (database access, response processing and so on) leaving only a JSON and the tempojs call to render it. I've also removed a lot of unnecesary imports and code comments:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="This is a report." />
<meta name="keywords" content="orientation:Portrait"/>
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.8.3/moment-with-locales.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.7.0/underscore.js"></script>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://raw.github.com/twigkit/tempo/master/tempo.min.js"></script>
<script type="text/javascript">

</script>
<script type="text/javascript">

$(window).bind("load", function() {
    var theBigTree = JSON.parse('[{"id":"c-03104678-AE5C-4538-B297-259A40FF9A80","name":"CLIENT A","teams":[{"id":"f-25E9E53C-7C4F-42CF-A2A8-81EF3F82940E","name":"123","players":[{"id":"a-BE9D684F-B9C4-43C4-A989-BE9E08173535","name":"0001609","description":"DNS 87 x 10","compliance_schedule":"current","compliance_inspection":"Not Compliant"}]}]},{"id":"c-62806657-A23D-4A4F-AD06-70A2C84F1757","name":"CLIENT B","teams":[{"id":"f-A84882B8-24E4-44E6-BDEA-D49190753D39","name":"ABC","players":[{"id":"a-A31F5485-75EC-4C2F-88C8-3D9D315EC354","name":"0001584","description":"Fair 141-14 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-F90AB955-F106-42D0-9DD5-114B7FCAC8EF","name":"0001585","description":"Fair 141-14 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-732ED35A-3C2C-4A22-9D47-D43D189CEBB8","name":"0001586","description":"Fair 141-14 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-BBBA13B2-3709-4995-8298-7A91412D29BB","name":"0001587","description":"Fair 141-14 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-1942CCC6-895C-43CA-BE1C-D7BEE193E008","name":"0001588","description":"Fair 141-14 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-D33317CC-EC63-497F-BAF4-E5881154BE02","name":"0001590","description":"Fair 141-14 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-116BAC43-F703-467F-B6A9-EFE8667B11EB","name":"0001593","description":"Fair 141-14 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"}]}]},{"id":"c-BC48BE3B-A9D8-48FA-9047-B6B486716DD2","name":"CLIENT C","teams":[{"id":"f-E32A6204-86AD-47F6-BCB9-16BE663203FB","name":"CDE","players":[{"id":"a-A8FE73C2-1FA1-4A7F-9C3F-110454C71085","name":"0001614","description":"Good 18 x 20 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-06255DF8-015E-42DA-B73B-DBCE3A5D7129","name":"0001615","description":"Good 12 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-72B822C8-8391-4ED3-8884-3934BAF49CFA","name":"0001618","description":"Good 8 x 10 HND","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-579BDBA0-2AE3-44BD-8C8A-D47525D70185","name":"0001619","description":"Good 8 x 10 HND","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-2D601DCC-3F0E-41E7-A7F0-FF1B2D5FA1FD","name":"0001620","description":"Good 8 x 10 HND","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-DF9EEF83-E8C9-4475-A7F6-E42F9E89795F","name":"0001621","description":"Good 8 x 10 HND","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-B311B0B2-4CE6-4220-9B76-861FDC7476C0","name":"0001622","description":"Good 8 x 10 HND","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-B0B75CC4-C28B-4673-A408-9E33F5842C24","name":"0001623","description":"Good 8 x 10 HND","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-7ED1D4E6-E40D-4307-9FC3-C0DB8CD1D7AB","name":"0001625","description":"Good 18 x 20 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"}]}]},{"id":"c-996AB994-DBFC-4388-B66A-A7957497E6E2","name":"CLIENT D","teams":[{"id":"f-436F5CFF-DCE3-41A4-9EAF-9518F752EDE8","name":"FGH","players":[{"id":"a-6ABF8430-8BAD-48A9-BFAD-85448F83A9E7","name":"0001722","description":"Good 9 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-FBF266AD-EB7D-447B-8B9F-658694C0E523","name":"0001723","description":"Good 9 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-F815569F-002D-4E48-88FA-D1B51F0A4B71","name":"0001726","description":"Good 9 x 10 HND","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-60360436-6FA0-42E9-A7F3-A2E7DD54FBA5","name":"0001729","description":"Good 12 x 10 CHN","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-FB3E9A6C-DD05-4ADF-8791-291EE655368C","name":"0001730","description":"Good 12 x 10 CHN","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-EAABD599-43F8-42B0-AE6E-C7D14462BD12","name":"0001731","description":"Good 12 x 10 CHN","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-EFEAA4FD-C244-41C5-931A-116C8E82ACE6","name":"0001732","description":"Good 10 x 10 CHN","compliance_schedule":"current","compliance_inspection":"Not Compliant"}]}]},{"id":"c-2AC042D3-3A2F-4D9C-B7A9-8B22827BDB75","name":"CLIENT E","teams":[{"id":"f-FC526C0C-DD3A-4CBC-976D-1A7CA6313A07","name":"HIJ","players":[{"id":"a-2CE7D70A-C444-4CB4-ADB2-1E92E45F309B","name":"0001708","description":"Good 12 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-0E2630DC-1A01-4077-92D4-37096E13F213","name":"0001709","description":"Good 12 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-4C4959B5-0E3D-454B-A088-158AE2275F33","name":"0001710","description":"Good 14 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-E69B2CFE-3FBD-4DE9-8E66-6DBD0CE8A468","name":"0001711","description":"Good 12 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-B150AF87-69E4-4BD6-8EB7-823BA1E09C37","name":"0001712","description":"Good 12 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-4A2362B4-3B9C-48C1-947E-CB99E73BFF39","name":"0001713","description":"Good 14 x 12 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-30191791-A320-45D2-A802-032FC60AE600","name":"0001714","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-C90A6B10-B319-4BFD-87C6-C7C25A931648","name":"0001715","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-392AC236-7E64-4CB4-9A07-3070B5E0E62D","name":"0001716","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-A5D79F6F-CA5D-4625-90F1-789825A49F96","name":"0001717","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-6BA176D0-BF5E-4745-AA0B-52E9DF914AD2","name":"0001718","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-73270EA5-F425-4B0E-A25E-A042AA5FB248","name":"0001719","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-89706A6B-A8FF-4F18-B1A7-9EF7770F4FE3","name":"0001720","description":"NON 12 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-0152535A-73F6-46F9-9337-141D2EC8CA1D","name":"0001721","description":"Good 12 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"}]}]},{"id":"c-F6178B77-45FA-4E07-B1F1-A0AAB0F97B22","name":"CLIENT F","teams":[{"id":"f-0D9A8DFF-BBA8-4F3D-8637-B43A83E178D0","name":"KLM","players":[{"id":"a-655D3D0C-F630-4C83-8EC8-81980A72AFDA","name":"0001254","description":"Good 16 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-7EC2CFA7-E068-4730-974D-D3666F616313","name":"0001255","description":"Good 16 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-86AC0836-3311-4568-877B-336ABD47D031","name":"0001539","description":"Good 10 x 10 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-811C9E7B-60ED-43FC-B237-FC93BD1C959F","name":"0001540","description":"Good 16 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-63370E1F-A4F5-4D6D-8B2F-2D89B4E601DD","name":"0001541","description":"Good 104 x 12 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-F88F3ED5-9138-4B29-B8EF-EF5708522E7D","name":"0001626","description":"Good 16 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-99B87F8C-F3F7-43EB-A418-5313C94AAED9","name":"0001627","description":"Good 16 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-93C7710A-E036-4AF9-B741-54A4F191B5D5","name":"0001628","description":"Good 16 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-7C67BAB8-CC35-49C2-AE6D-8D5DE721F976","name":"0001629","description":"Good 16 x 14 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-5CC975CC-0BC4-4C00-8884-226A9CDF153E","name":"0001630","description":"Good 18 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-73CAF410-B0C5-42F9-A66B-92956096AB50","name":"0001631","description":"Good 18 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-758F2352-02C6-4210-9D9B-40A4F757BC14","name":"0001632","description":"Good 18 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-765A4544-ADE9-44DD-BD5B-C35540E0EB1A","name":"0001633","description":"Good 18 x 16 EO","compliance_schedule":"current","compliance_inspection":"Unknown Compliance"}]}]},{"id":"c-DEC92495-59C0-4193-845E-8562BB3C901C","name":"CLIENT G","teams":[{"id":"f-E4333E5E-7DCC-4F1D-804B-E3D0A2B21AD4","name":"NOP","players":[{"id":"a-0ECF79EF-3048-49C5-8044-3059F6C32F3D","name":"0001308","description":"Good 18 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-19C83D60-1BF9-4454-B5E3-C34A9F284767","name":"0001309","description":"Good 18 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-C33A6D2C-BA52-4BF5-9DC6-BC1FF996A1D8","name":"0001310","description":"Good 18 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-3E2319CA-A418-46FB-96E0-B08637471C8C","name":"0001311","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-526E2C41-9D49-4C77-9A15-F2008D2AF6B3","name":"0001312","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-057D1B1B-D0FF-4B86-82D3-EDF703B8C387","name":"0001313","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"},{"id":"a-4FD29E74-CC55-4B2A-BA24-7BF81BBEAC86","name":"0001314","description":"Good 16 x 16 EO","compliance_schedule":"current","compliance_inspection":"Not Compliant"}]}]}]');
    Tempo.prepare('customer-non-compliant-player-list').render(theBigTree);
});

</script>
<style type="text/css">

#customer-non-compliant-player-list th {
    border-top: solid 1px #7E7E7E;
    border-bottom: solid 1px #7E7E7E;
    border-left: solid 1px #7E7E7E;
    border-right: solid 1px #7E7E7E;
    text-align: center;
    padding: 1%;
    background-color: #D9D9D9;
}

#customer-non-compliant-player-list td {
    border-top: solid 1px #7E7E7E;
    border-bottom: solid 1px #7E7E7E;
    border-left: solid 1px #7E7E7E;
    border-right: solid 1px #7E7E7E;
    padding: 0.5%;
}

#customer-non-compliant-player-list table {
    border-collapse: collapse;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}

#customer-non-compliant-player-list .text-large {
    font-size: 18px;
}

#customer-non-compliant-player-list .customer-column {
    vertical-align:top;
    font-weight: bold;
    width: 10px;
}

#customer-non-compliant-player-list .team-column {
    vertical-align:top;
    width: 17%;
}

#customer-non-compliant-player-list .team-column-header {
    width: 14%;
}

#customer-non-compliant-player-list .id-column {
    width: 11%;
}

#customer-non-compliant-player-list .description-column {
    width: 20%;
}

#customer-non-compliant-player-list .inspection-column {
    width: 17%;
    text-transform: capitalize;
}

#customer-non-compliant-player-list .schedule-column {
    width: 19%;
    text-transform: capitalize;
}

#customer-non-compliant-player-list .border-bottom-only {
    border-top: none;
    border-right: none;
    border-left: none;
}

#customer-non-compliant-player-list .no-border {
    border-top: none;
    border-bottom: none;
    border-right: none;
    border-left: none;
}

#customer-non-compliant-player-list #players-table tr:last-child td {
    border-bottom:0;
}

#customer-non-compliant-player-list #players-table {
    padding: -2px;
    border-collapse: collapse;
}
.no-border {
    border: none;
}

.width-50pc {
    width: 50%;
}

#customer-non-compliant-player-list table {
    width: 100%;
    margin: auto;
}
</style>
</head>
<body>
<title>This is the title</title>


<p></p>


<div id="customer-non-compliant-player-list">
    <table>
        <th>THIS IS THE TITLE</th>
    </table>
    <br>
    <table id="customers">
        <tr data-before-template='data-before-template'>
            <th class="customer-column">CUSTOMER</th>
            <th class="team-column-header">TEAM</th>
            <th class="id-column">PLAYER</th>
            <th class="description-column">DESCRIPTION</th>
            <th class="inspection-column">INSPECTION</th>
            <th class="schedule-column">SCHEDULE</th>
        </tr>
        <tr data-template='data-template'>
            <td class="customer-column">{{name}}</td>
            <td colspan="5">
                <table class="no-border">
                    <tr data-template-for='teams'>
                        <td class="team-column no-border">{{name}}</td>
                        <td class="no-border">
                            <table class='player-table no-border' >
                                <tr data-template-for="players" >
                                    <td class="id-column no-border">{{name}}</td>
                                    <td class="description-column no-border">{{description}}</td>
                                    <td class="inspection-column no-border">{{compliance_inspection}}</td>
                                    <td class="schedule-column no-border">{{compliance_schedule}}</td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div></body>
</html>

You'll notice I pasted two different header files. In the case of header1.html, the header text "THIS IS THE HEADER" is displayed correctly in both the 1st page and the second one. However, as soon as I import moment js from http://momentjs.com/downloads/moment.min.js like header2.html has, the text "THIS IS THE HEADER" is only displayed on the first page. The second page shows a blank space with no text.
Additionally, I tried this with wkhtmltopdf 0.12.1 (with patched qt) as well and I got the same results.

12 2 1_withoutmomentjs
12 2 1_withmomentjs

@faustow faustow changed the title v0.12.2.1 - Page headers given in --header-html only shown in the first page of PDF file v0.12.2.1 and 0.12.1 - Page headers given in --header-html only shown in the first page of PDF file Apr 23, 2015
@ashkulz ashkulz reopened this Apr 24, 2015
@ghost
Copy link

ghost commented Oct 1, 2015

I found out this:
When you include an external javascript file anywhere in the header html file ("src=...") plus you specify top margin via command line ("-T ..."), the query part of the location will only be passed to the very first header. When any included script crashes (because of trying to access the non existing query part), the header will not be rendered at all, if you included the script in the html HEADER block.

Here is a minimal example:

header-html

<!DOCTYPE html>
<html>
<body style="margin:0;border: 1px solid red;">
  HEADER-LOCATION<br>
  <script src="Test.js"></script><br>
  <!-- <script>document.write(document.location)</script><br> -->
  /HEADER-LOCATION
</body>
</html>

Test.js

document.write(document.location);

Document.htm

<!DOCTYPE html>
<html>
<body>
  THE DOCUMENT.
</body>
</html>

Command Line

wkhtmltopdf4 -T 30 --header-html Header.htm Document.htm --header-html Header.htm Document.htm Test.pdf

Remarks

  • When executing this example you will see that the document.location of the 2nd header is incomplete
  • When you omit the "-T 30" argument (automatic height) it will work
  • When you paste the javascript code into the html instead of referring it via "src" it will work

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