Как напечатать указанное c количество таблиц на странице? - PullRequest
0 голосов
/ 25 февраля 2020

Пока я работал над проектом, мне нужно было создать около 2000 небольших таблиц, которые я также должен распечатать на страницах. Я генерировал эти таблицы с помощью for l oop в моем проекте django с использованием кода jinja. Вот я прилагаю пример кода -

{% load static %}
{% load tempos %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
    <link rel="stylesheet" type="text/css" href="{% static 'css/bcard/bcard.css' %}">
    <title>bcoutput</title>
</head>
<body>
<div class="container">
    <div class="row">
    {% for i in 30|get_range %}
        <div class="col-lg-4">
        <table class="table pagebreak table-bordered">
          <thead>
            <tr>
              <th scope="col">#</th>
              <th scope="col">First</th>
              <th scope="col">Last</th>
              <th scope="col">Handle</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <th scope="row">1</th>
              <td>Mark</td>
              <td>Otto</td>
              <td>@mdo</td>
            </tr>
            <tr>
              <th scope="row">2</th>
              <td>Jacob</td>
              <td>Thornton</td>
              <td>@fat</td>
            </tr>
            <tr>
              <th scope="row">3</th>
              <td colspan="2">Larry the Bird</td>
              <td>@twitter</td>
            </tr>
          </tbody>
        </table>
        </div>
    {% endfor %}
    </div>
</div>
</body>
</html>

Используемый мной файл css:

@page {
    size: A4;
    margin: 0;
}

@media print {
    body {
        width:100%
        height:100%
    }

    table {
        width: 30% !important;
        height: 50% !important;

    }

.pagebreak {
    page-break-inside:avoid;
}

}

Теперь проблема, с которой я сталкиваюсь, - я хочу создать 6 таблиц в трех столбцах на странице при печати страниц. Но независимо от того, что я делаю в разделе css, это не дает мне должного результата. Текущий предварительный просмотр печати -

enter image description here

Есть кто-нибудь, чтобы помочь?

...