【问题标题】:Using cfdocument to generate PDF使用cfdocument生成PDF
【发布时间】:2010-10-21 00:03:34
【问题描述】:

实际的桌子比我要给你看的模型大很多,但是这个模型确实解释了这个问题。请转至http://www.monteandjanicechan.com/test_table.cfm

表格中网格线的粗细在 HTML 版本中按我想要的方式显示。您可以查看源代码来查看生成的实际 HTML 内容。现在,我将这些 HTML 代码放在 cfdocument 标记中,格式为 format="pdf";请转至http://www.monteandjanicechan.com/test_table_pdf.cfm。您会看到打喷嚏和流感的网格线粗细不一致。为了进一步说明我的观点,我删除了背景颜色并生成了 PDF;请转至http://www.monteandjanicechan.com/test_table_pdf_nocolor.cfm。网格线的粗细恢复正常。

这让我相信一个单元格的背景颜色会以某种方式超越它旁边的单元格并覆盖边框。以下是奇怪的事情:

1) 这仅发生在行跨度中,并且仅发生在从第二行到行跨度的其余部分。例如,第一次打喷嚏可以,但第二次打喷嚏的边界不正确;第一次流感还可以,但第二次和第三次流感的边界不正确。

2) 背景颜色根本不覆盖自己单元格的边框;它只覆盖它旁边的单元格的边框。

我的问题是,我该如何解决这个问题?

非常感谢任何建议和指点。

【问题讨论】:

    标签: css coldfusion cfdocument


    【解决方案1】:

    HTML 版本的粗细也不同。我认为问题在于您的 CSS 规则。

    这可以按照我的想法工作,尽管它可能会得到改进。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
      <head>
        <title>Test Table</title>
        <style type="text/css">
        td { 
            border-top: 1px solid black; 
            border-left: 1px solid black; 
        }
        .right { border-right: 1px solid black; }
        .bottom {border-bottom: 1px solid black; }
        </style>
      </head>
      <body>
    <table border="0" cellspacing="0" cellpadding="5">
      <tr>
    
        <td class="a_style">Name</td>
        <td class="a_style">Problem</td>
        <td class="right">Treatment</td>
      </tr>
      <tr>
        <td class="b_first">Jane Doe</td>
        <td class="c_first" style="background-color:#ffff99">Cough</td>
    
        <td class="right" style="background-color:#ffff99">Vitamins</td>
      </tr>
      <tr>
        <td class="b">John Doe</td>
        <td class="c" style="background-color:#99FF99">Sneezing</td>
        <td class="right" rowspan="2" style="background-color:#99FF99">Nose Spray</td>
      </tr>
    
      <tr>
        <td class="b">Joe Schmo</td>
        <td class="" style="background-color:#99FF99">Sneezing</td>
      </tr>
      <tr>
        <td class="b">Joe Six Pack</td>
        <td class="c" style="background-color:#cccccc">Flu</td>
    
        <td class="right bottom" rowspan="3" style="background-color:#cccccc">Flu Shot</td>
      </tr>
      <tr>
        <td class="b">Joe The Plumber</td>
        <td class="" style="background-color:#cccccc">Flu</td>
      </tr>
      <tr>
    
        <td class="bottom">Joe Doe</td>
        <td class="bottom" style="background-color:#cccccc">Flu</td>
      </tr>
    </table>
    </body>
    </html>
    

    【讨论】:

    • 不,这不是我想要的。就像我写的那样,monteandjanicechan.com/test_table.cfm 正是我希望桌子看起来的样子。某些网格比其他网格更大胆;这是故意的。更粗的网格用于划分类别,这就是我的客户想要的。
    • 如果可以,请将monteandjanicechan.com/test_table.cfmmonteandjanicechan.com/test_table_pdf.cfm 并排放置。对于 Joe Schmo 和 John Doe 来说,打喷嚏都是他们的问题。查看这两行的处理单元格。治疗的左边框(鼻喷雾)仅适用于 PDF 中的 John Doe,但不适用于 Joe Schmo。同样,Joe Six Pack、Joe The Plumber 和 Joe Doe 都将流感疫苗作为治疗方法。但是,流感疫苗的左边框仅适用于 Joe Six Pack,而不适用于 Joe The Plumber 和 Joe Doe。这就是我所指的不均匀性。
    • 啊,我明白你的意思了。当我放大时,颜色向右和/或向下移动 1 个像素。这就是导致问题的原因,我只是不知道您如何解决它。如果cfdocument 格式也是flashpaper,它会这样做吗?这可能只是 PDF 生成器的一个错误。
    • 好吧,我想出了一个“修复”。我没有在边框中做 1px right 和 1px right ,而是将其更改为 2px right 并且没有左边框。现在,网格线确实按我想要的方式显示了;但是,由于背景颜色“溢出”了 1px 并与部分网格线重叠,因此与网格线接触的水平边框似乎没有连接。
    猜你喜欢
    • 1970-01-01
    • 2012-05-24
    • 1970-01-01
    • 1970-01-01
    • 2022-07-04
    • 1970-01-01
    • 2021-09-08
    • 2011-07-27
    • 2014-07-03
    相关资源
    最近更新 更多