【问题标题】:Horizontal border is missing in table border on page break on converting cshtml page to pdf将cshtml页面转换为pdf时分页符的表格边框中缺少水平边框
【发布时间】:2016-08-24 13:49:25
【问题描述】:

我正在打印一个包含许多表格的 pdf 格式的大型报告,但它通常不包含水平单元格边框。 为此,我在cshtml 中生成了报告,然后使用NRECO 将其传递给pdf

现在发生的情况是,当我的表格更大并且页面中断到另一个页面时,我的表格中没有水平线。

但是当我在 Pdf 中分页时,我希望我的表格中有水平边框。目前我在第 1 页最后有 1 个长表,我没有得到水平边框。

见下图:Horizontal border problem in table

 <table border="0" cellpadding="0" cellspacing="0" class="width100percent">
                                        <thead>
                                            <tr>
                                                <th></th>
                                                <th></th>
                                                <th></th>
                                                ...
                                                ...
                                           </tr>
                                        </thead>
                                        <tbody>
                                           <tr>
                                                <td></td>
                                                 <td></td>
                                                 <td></td>
                                                ...
                                                ...
                                           </tr>
                                        </tbody>
        </table

【问题讨论】:

  • 这是我的 css .border-table tr td { padding: 0 3px;字体大小:11px;文本转换:大写;高度:18px;字体粗细:500;字体系列:Calibri;左边框:1px 实心#000000; page-break-inside:避免;分页后:自动; }
  • 此问题仅在生成 pdf 时出现,在浏览器中工作正常。

标签: css pdf-generation wkhtmltopdf html-to-pdf


【解决方案1】:

我一直在查看您的代码并尝试重现您的问题。在您的 CSS 中,单元格元素的边框仅位于左侧,因此生成包含的示例图像似乎不完整。

以下是基于您的内容构建的 HTML 页面示例:

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Horizontal border problem in table</title>
    <style>
        table.width100percent {
            width: 100%;
            border-width: 0;
            border-spacing: 0;
        }

        .border-table tr td {
            padding: 0 3px;
            font-size: 11px;
            text-transform: uppercase;
            height: 18px;
            font-weight: 500;
            font-family: Calibri;
            border-left: 1px solid #000000;
            page-break-inside: avoid;
            page-break-after: auto;
        }
    </style>
</head>

<body>
    <div class="border-table">
        <table class="width100percent">

...此处为完整文档:https://pastebin.com/MNuwWNYG

我也尝试将其转换为NReco,但如上所示,没有可使用的水平边框。生成的 PDF 如下所示:https://imgur.com/a/HNlpkSX

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 2015-10-09
    • 2013-02-27
    • 2017-10-23
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    相关资源
    最近更新 更多