Footers And Headers
Headers and footers can be added to the document by the --header-*
and --footer*
arguments respectfully. In header and footer text string supplied to e.g. —header-left, the following variables will be substituted.
[page]
Replaced by the number of the pages currently being printed[frompage]
Replaced by the number of the first page to be printed[topage]
Replaced by the number of the last page to be printed[webpage]
Replaced by the URL of the page being printed[section]
Replaced by the name of the current section[subsection]
Replaced by the name of the current subsection[date]
Replaced by the current date in system local format[isodate]
Replaced by the current date in ISO 8601 extended format[time]
Replaced by the current time in system local format[title]
Replaced by the title of the of the current page object[doctitle]
Replaced by the title of the output document[sitepage]
Replaced by the number of the page in the current site being converted[sitepages]
Replaced by the number of pages in the current site being converted
As an example specifying —header-right “Page [page] of [toPage]”, will result in the text “Page x of y” where x is the number of the current page and y is the number of the last page, to appear in the upper left corner in the document.
Headers and footers can also be supplied with HTML documents. As an example one could specify --header-html header.html
, and use the following content in header.html:
<html><head><script>
function subst() {
var vars = {};
var query_strings_from_url = document.location.search.substring(1).split('&');
for (var query_string in query_strings_from_url) {
if (query_strings_from_url.hasOwnProperty(query_string)) {
var temp_var = query_strings_from_url[query_string].split('=', 2);
vars[temp_var[0]] = decodeURI(temp_var[1]);
}
}
var css_selector_classes = ['page', 'frompage', 'topage', 'webpage', 'section', 'subsection', 'date', 'isodate', 'time', 'title', 'doctitle', 'sitepage', 'sitepages'];
for (var css_class in css_selector_classes) {
if (css_selector_classes.hasOwnProperty(css_class)) {
var element = document.getElementsByClassName(css_selector_classes[css_class]);
for (var j = 0; j < element.length; ++j) {
element[j].textContent = vars[css_selector_classes[css_class]];
}
}
}
}
</script></head><body style="border:0; margin: 0;" onload="subst()">
<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>
As can be seen from the example, the arguments are sent to the header/footer html documents in get fashion.