【问题标题】:PDFlib table border only on bottom of rowPDFlib 表格边框仅位于行的底部
【发布时间】:2021-08-31 07:02:27
【问题描述】:

是否可以在 PDFlib 中仅为表格的特定行定义边框?我知道我们有笔画选项,类似于stroke={{line=horother}},它为整个表格创建了一个边框(就像在示例中为所有水平线一样),但这并不是我想要实现的。我想为一些行定义底部边框(具体来说,我不希望标题行和最后一行有任何边框)。

【问题讨论】:

  • 你试过pdflib.com ??也请看看stackoverflow.com/tour
  • @Erik 是的,我查看了 pdflib.com,但直到现在我还没有找到我的问题的答案。
  • 他们有非常丰富的文档
  • @Erik 谢谢,但就像我说的,我还没有在那里找到我的问题的答案。 pdflib 文档始终是我首先要看的地方。

标签: php pdf pdflib


【解决方案1】:

您正在寻找笔画选项“hor#”,其中# 是您要绘制的行数。 hor0 是上边框。

来自 PDFlib 9.3.1 教程,第 5.3 章,第 5.18 章“PDF_fit_table( ) 的选项”:

stroke (List of option lists) This option can be used to create stroked lines at the cell borders:
  line (Keyword) Table line(s) to be stroked:
    vert#      vertical line at the right border of column number #; vert0 is the left table border
    vertfirst  first vertical line (equivalent to vert0)
    vertlast   last vertical line
    vertother  all unspecified vertical lines
    hor#       horizontal line at the bottom of row number # in the table; hor0 is the top border
    horfirst   first horizontal line in the table instance
    horother   all unspecified horizontal lines
    horlast    last horizontal line in the table instance frame outer border of the table
    other      all unspecified lines

您还可以在 PDFlib Cookbook (Table contact sheet) 中找到相应的示例。

    /* Prepare the option list for fitting the table.
     * The "stroke" option will stroke every vertical line and every
     * second horizontal line in white with a line width of 0.3.
     * The "fill" option fills the complete table with a dark gray.
     */
    $stroke_opts = 
        "stroke={{line=vertother strokecolor={gray 1} linewidth=0.3}";
    
    for ($i = 0, $j = 2; $i < count($imagefiles); $i += $nocols, $j+=2) {
        $stroke_opts .=
            " {line=hor" . $j . " strokecolor={gray 1} linewidth=0.3}";
    }
    $stroke_opts .= "} ";

如果您想更精确地控制它,add_table_cell() 选项列表中的 matchbox 选项可能值得考虑。这将允许您自定义每个单元格,如 colorize_cell Cookbook 示例中所示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2017-03-29
    • 1970-01-01
    • 2012-06-04
    • 2020-05-24
    • 2012-04-19
    • 2018-06-24
    相关资源
    最近更新 更多