I would like to print large html content with header and footer repeat in all pages without overlapping using printThis.js plugin.
But header and footer is not repeating.
$("#printKitten").click(function () {
$("#divContent").printThis({
header: $('#divHeader').html,
footer: $('#divFooter').html
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="../Scripts/jquery-3.0.0.min.js"></script>
<script src="../Scripts/printThis.js"></script>
<button id="printKitten">Print</button>
<div id="divHeader">
HEADER <br />HEADER <br />HEADER <br />HEADER <br />HEADER <br />HEADER <br />
</div>
<div id="divContent">
<p>Content placeholder START...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...</p>
<p>Content placeholder ...END</p>
</div>
<div id="divFooter">
footer <br />footer <br />footer <br />footer <br />footer <br />footer <br />
</div>
I tried with @media print also but no luck.
printThisdoesn't seem to have this feature.You could request it.
In the meantime, you may want to consider this approach, using CSS. It makes use of a
tableelement, where itstheadandtfootrepeats, but itstbodydoesn't repeat.Quoting the basic setup:
Important notes according to author:
Main content
CSS
Go check that article. It's very well explained and may server as a great workaround.