简体   繁体   中英

window.print() cut some content but no other

Im doing a page to visualice the content of some tables(mysql) and then I thought to do a button to print this tables but some tables cut the content. I will post the table to print and some images.

The code of the table to print:

<?php
$a = $index - 1;
echo "<div id='{$a}' class='table-responsive d-block'>"
?>
<table class="table table-bordered table-hover table-striped">
    <thead>
        <tr>
            <?php
            $val = [];
            $sql = "SHOW COLUMNS FROM {$valor}";
            $result = $connection->query($sql);
            while ($row = mysqli_fetch_array($result)) {
                echo "<th class='text-secondary col-md-auto text-capitalize'>{$row['Field']}</th>";
                $val[] = $row['Field'];
            }
            ?>
        </tr>
    </thead>
    <tbody>
        <?php
        $sql = "SELECT * FROM {$valor}";
        $result = $connection->query($sql);
        if (!$result) {
            echo ("No se encontro resultado");
            die("Invalid query: " . $connection->error);
        }
        while ($row = $result->fetch_assoc()) {
            echo "<tr>";
            foreach ($val as &$campo) {
                if (isset($row['Link']) && !empty($row['Link'])) {
                    echo "<td class='text-primary' id='{$campo}'><a style='text-decoration: none;' target='_blank' href='{$row['Link']}'>$row[$campo]</a></td>";
                } elseif (isset($row['Marca']) && isset($row['Modelo']) && !empty($row['Marca']) && !empty($row['Modelo'])) {
                    echo "<td class='text-primary' id='{$campo}'><a style='text-decoration: none;' target='_blank' href='http://www.google.com/search?q={$row['Marca']}+{$row['Modelo']}'>$row[$campo]</a></td>";
                } else {
                    echo "<td class='text-primary' id='{$campo}'>$row[$campo]</td>";
                }
            }
            echo "</tr>";
        }
        ?>
    </tbody>
</table>
</div>

And some examples:

Perfect example Bad example

please... I'm trying to make the question clear, to answer well and to do my best, don't ban my post as usual or insult me. English is not my forte either, I do what I can, constructive criticism would help me much more.

I only want that table with long link, dont be cut. Maybe a solution is deleting links and write shorcuts?

Well, finally I got the solution:

class='text-wrap'

From boostrap.

That's works too:

@media print { 
  table,
  table tr td,
  table tr th {
    page-break-inside: avoid;
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM