簡體   English   中英

window.print() 剪切了一些內容但沒有其他內容

[英]window.print() cut some content but no other

我正在做一個頁面來可視化某些表 (mysql) 的內容,然后我想做一個按鈕來打印這些表,但有些表會剪切內容。 我將張貼要打印的表格和一些圖像。

要打印的表的代碼:

<?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>

還有一些例子:

完美的例子壞的例子

請...我正在努力使問題清楚,回答好並盡力而為,不要像往常一樣禁止我的帖子或侮辱我。 英語也不是我的強項,我盡力而為,建設性的批評會幫助我更多。

我只想要那個有長鏈接的表,不要被砍掉。 也許解決方案是刪除鏈接並編寫快捷方式?

好吧,最后我得到了解決方案:

class='text-wrap'

來自助推器。

這也行得通:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM