我是PDFlib的新手,同样需要指导。我在pdflib中添加了一个表,我的一行中有一个文本是it.Now的,我只希望文本的数量和日期部分以粗体显示,任何知道我怎么做的都行。这就是我现在所拥有的;
$font = $p->load_font("Helvetica", "unicode", "");
$optlistFourthRowFirstColumnTbl3 = "colwidth=100 colspan=4 fittextline={position={left bottom} font=" . $font . " fontsize=7.5}";
$row4Text = "\n\nYour Total amount is ".$aData['price']['total price']." ".$aData['currency']." and should be paid by".$invoiceDateOfPayment->format( 'd.m.Y' )." at the latest.";
$tbl3 = $p->add_table_cell( $tbl3, 1, $row, $row4Text, $optlistFourthRowFirstColumnTbl3 );
$row++;但这只是给了我正常的全文,我想要的是这样;
您的总金额为45.00美元,最迟应由21.05.2020支付。
发布于 2020-04-21 09:54:47
这样的单元格需要粗体字体。您可以在PDFlib食谱中的代码示例中看到这一点:表格在标题描述中使用粗体文本单元格。
/* ---------- 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);
} /* 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来执行隐式encoding(),如:
$optlist = "fittextline={fontname=NotoSerif-Bold encoding=unicode fontsize=12" .
" position=center} margin=4 colspan=3 colwidth=" . $c1;starter_table.php示例还包含在bind/php目录(或任何其他受支持的绑定)中的PDFlib 9下载包中。
https://stackoverflow.com/questions/61337862
复制相似问题