首页
学习
活动
专区
圈层
工具
发布

PDFLib表
EN

Stack Overflow用户
提问于 2020-04-21 07:13:44
回答 1查看 268关注 0票数 0

我是PDFlib的新手,同样需要指导。我在pdflib中添加了一个表,我的一行中有一个文本是it.Now的,我只希望文本的数量和日期部分以粗体显示,任何知道我怎么做的都行。这就是我现在所拥有的;

代码语言:javascript
复制
$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支付。

EN

回答 1

Stack Overflow用户

发布于 2020-04-21 09:54:47

这样的单元格需要粗体字体。您可以在PDFlib食谱中的代码示例中看到这一点:表格在标题描述中使用粗体文本单元格。

代码语言:javascript
复制
    /* ---------- 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);
}

表/混合表内容

代码语言:javascript
复制
    /* 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={}选项中应用字体句柄。当然,您也可以使用选项fontnameencoding来执行隐式encoding(),如:

代码语言:javascript
复制
$optlist = "fittextline={fontname=NotoSerif-Bold encoding=unicode fontsize=12" .
    " position=center} margin=4 colspan=3 colwidth=" . $c1;

starter_table.php示例还包含在bind/php目录(或任何其他受支持的绑定)中的PDFlib 9下载包中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61337862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档