WKHTMLTOPDF: How to disable header on the first page

后端 未结 5 1570
终归单人心
终归单人心 2021-02-06 03:39

wkhtml doesn´t repeat table elements \"th\" on every page like it should. So I thought it could be possible to simply use the --header-html option and add the table headers manu

5条回答
  •  礼貌的吻别
    2021-02-06 04:01

    Did you try the JS solution? It's actually not that complicated. I just did a test with a long html file that contained a table that is split into many different pages and I managed to remove the headers from page 1 and 3 using this header file:

    
        
            
            
        
        
            
    Your awesome table column header 1 Column 2 Page /

    They key points to not there is that the table "headers" are contained in a table that has the ID "FakeHeaders". The javascript function subst() is run when the body is loaded and during the function it checks if the current page is 1 or if the current page is 3 and if it is, the FakeHeaders is set invisible. You will need to play with the margins and CSS to get it to look like you want but this Should work.

    This is a known problem with wkhtmltopdf and most likely it won't be fixed any time soon, see issue 566 in the issue tracker. I see the JavaScript option as the only usable workaround, but you can try playing around with divs or manually splitting the tables if your input html, style and page sizes/margins are very predictable - but be warned, it will be really annoying.

提交回复
热议问题