您需要为此类单元格使用粗体。您可以在 PDFlib 说明书的代码示例中看到这一点:
table/starter_table 在标题描述中使用粗体文本单元格。
/* ---------- row 1: table header (spans all columns) */
$row = 1; $col = 1;
$font = $p->load_font("NotoSerif-Bold", "unicode", "");
if ($font == 0) {
echo("Error: " . $p->get_errmsg());
exit(1);
}
$optlist = "fittextline={position=center font=" . $font . " fontsize=14} " .
"colspan=" . $colmax;
$tbl = $p->add_table_cell($tbl, $col, $row, $headertext, $optlist);
if ($tbl == 0) {
echo("Error: " . $p->get_errmsg());
exit(1);
}
或table/mixed table contents
/* Load the font */
$boldfont = $p->load_font("Helvetica-Bold", "unicode", "");
if ($boldfont == 0)
throw new Exception("Error: " . $p->get_errmsg());
...
/* ---------------------
* Adding the first cell
* ---------------------
*
* The cell will be placed in the first column of the first row and will
* span three columns.
* The first column has a width of 50 points.
* The text line is centered vertically and horizontally, with a margin
* of 4 points from all borders.
*/
$optlist = "fittextline={font=" . $boldfont . " fontsize=12" .
" position=center} margin=4 colspan=3 colwidth=" . $c1;
$tbl = $p->add_table_cell($tbl, 1, 1, "Our Paper Plane Models", $optlist);
您可以在 fittextline={} 选项中应用字体句柄。当然你也可以通过使用fontname 和encoding 选项来做一个隐式的load_font(),比如:
$optlist = "fittextline={fontname=NotoSerif-Bold encoding=unicode fontsize=12" .
" position=center} margin=4 colspan=3 colwidth=" . $c1;
starter_table.php 示例也包含在 PDFlib 9 下载包中的 bind/php 目录(或任何其他支持的绑定)中