|
<script>
var currentValue = "";
var headerValue = "Header Content when print";
var footerValue = "Footer Content when print";
function onCreate() {
defaultRTE = this;
}
function actionBeginFunc(args) {
if (args.requestType === "print") {
currentValue = args.element.innerHTML;
args.element.innerHTML =
`<div class="page-header" style="text-align: center">` +
headerValue +
`</div>
<div class="page-footer" style="border-top: 1px solid black;position: fixed; bottom: 0; width: 100%;">` +
footerValue +
`</div>
<table>
<thead>
<tr>
<td>
<!--place holder for the fixed-position header-->
<div class="page-header-space"></div>
</td>
</tr>
</thead>
<tbody>
<tr>
<td><div class="page">` +
args.element.innerHTML +
`</div>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>
<div class="page-footer-space"></div>
</td>
</tr>
</tfoot>
</table>`;
}
}
function actionCompleteFunc(args) {
if (args.requestType === "print") {
defaultRTE.inputElement.innerHTML = currentValue;
}
}
</script>
<style>
body {
touch-action: none;
}
/* Styles for Header and footer when Print */
.page-header,
.page-header-space {
height: 100px;
}
.page-footer,
.page-footer-space {
height: 50px;
}
.page-footer {
position: fixed;
bottom: 0;
width: 100%;
border-top: 1px solid black;
}
.page-header {
position: fixed;
top: 0mm;
width: 100%;
border-bottom: 1px solid black;
}
.page {
page-break-after: always;
margin-top: 80px;
}
@@page {
margin: 20mm;
}
@@media print {
thead {
display: table-header-group;
}
tfoot {
display: table-footer-group;
}
button {
display: none;
}
body {
margin: 0;
}
}
</style> |