JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container" id="print_this">
<div class="row">
<div class="col-lg-12">
<table class="table">
<tbody><tr>
<td>Начальник </td>
<td>
<span>
Агєєв П.О.
</span>
</td>
</tr>
<tr>
<td>Майстри </td>
<td>
<span>
Кошелєв С.В.; Осадченко О.О.; Присяжний Ю.А.; Солодар В. О.; Толочко С.М.
</span>
</td>
</tr>
<tr>
<td>Диспетчери </td>
<td>
<span>
Гавриленко Н.В.; Зазимко О.М.; Лубанова А.І.; Сіренко Г. Р.; Шевчук О.О.
</span>
</td>
</tr>
<tr>
<td>Зварювальники </td>
<td>
<span>
Вдовиченко І.В.; Вдовіченко; Рославцев Є.С.; Рябець С.В.; Семененко В.П.
</span>
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="row">
<div class="col-lg-3">
<table class="table table-bordered">
<tbody><tr class="shadow">
<td>1 виїзд</td>
<td> <span>
</span>
</td>
</tr>
<tr>
<td>
Гавриленко Н.В.
</td>
<td>
Диспетчер
</td>
</tr>
<tr>
<td>
Волошин В.В.
</td>
<td>
Слюсар
</td>
</tr>
<tr>
<td>
Ісаков В.А.
</td>
<td>
Слюсар
</td>
</tr>
...
CSS
@@media screen {
#printSection {
display: none;
}
}
@@media print {
body * {
visibility: hidden;
max-height: 850px;
}
#printSection, #printSection * {
visibility: visible;
}
#printSection {
position: absolute;
left: 0;
top: 0;
/*width: 100%;
height:100%;
border:solid 2px #ff0000;*/
}
}
/*@@page {
size: A4;
margin: 10px;
}*/
#print_this {
width: 28cm;
}
#print_this {
/*min-height: 29.7cm;*/
}
.shadow {
background-color: #ebdddd;
}
JavaScript
$(document.body).on('click', "#print", function (e) {
printElement(document.getElementById("print_this"));
window.print();
});
function printElement(elem, append, delimiter ) {
var domClone = elem.cloneNode(true);
var $printSection = document.getElementById("printSection");
if (!$printSection) {
var $printSection = document.createElement("div");
$printSection.id = "printSection";
//var css = document.createElement("style");
//css.type = "text/css";
//css.href = 'http://localhost:1392/Content/bootstrap.css';
//document.body.appendChild(css);
document.body.appendChild($printSection);
}
if (append !== true) {
$printSection.innerHTML = "";
}
else if (append === true) {
if (typeof (delimiter) === "string") {
$printSection.innerHTML += delimiter;
}
else if (typeof (delimiter) === "object") {
$printSection.appendChlid(delimiter);
}
}
$printSection.appendChild(domClone);
}
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
// document.body.innerHTML = printContents;
window.print();
// document.body.innerHTML = originalContents;
}