PDFlib table 边框仅在行底部

PDFlib table border only on bottom of row

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

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

来自 PDFlib 9.3.1 教程,第 5.3 章,第 Table 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() 选项列表中的匹配框选项可能值得考虑。这将允许您自定义每个单元格,如 colorize_cell Cookbook 示例中所示。