У меня давно эта проблема. Я печатаю таблицу, которая находится внутри модального окна, содержимое, показанное в предварительном просмотре печати, нормально, но после таблицы остается большой кусок белого пространства. И выглядит так. Он показывает две страницы на одной только для объяснения моей проблемы, а серый фон можно отключить, просто сняв флажок фоновой графики.
Это код, который я использую для печати и это в моем индексе "_fields" - это идентификатор div, который я хочу напечатать.
@section Scripts {
<script src="~/js/areas/human-resources/payrollmovement/index.js"></script>
<script>
$(document).ready(function () {
document.getElementById("btn-print").onclick = function () {
printElement("_fields");
}
function printElement(div) {
// Create and insert new print section
var elem = document.getElementById(div);
var domClone = elem.cloneNode(true);
var $printSection = document.createElement("div");
$printSection.id = "printSection";
$printSection.appendChild(domClone);
document.body.insertBefore($printSection, document.body.firstChild);
window.print();
// Clean up print section for future use
var oldElem = document.getElementById("printSection");
if (oldElem != null) { oldElem.parentNode.removeChild(oldElem); }
return true;
}
});
</script>}
Это мой css
@media screen {
#printSection {
display: none;
}
}
@media print {
body * {
visibility: hidden;
}
#printSection, #printSection * {
visibility: visible !important;
}
#printSection {
position: absolute;
left: 0;
top: 0;
}
.modal-open .wrapper {
display: none !important;
visibility: hidden !important;
}
}
Я хочу удалить этот белый пробел после таблицы и способ дублирования таблицы.