I am new to PDFlib and need guidance in the same. I have added a table in pdflib and one of my row has a text in it.Now I only want the amount and date part of the text to be in bold, any idea how I can do it. This is what I have 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++;
but this just gives me the entire text in normal and what I want is like this;
Your Total amount is 45.00 $ and should be paid by 21.05.2020 at the latest.
you need a bold font for such cell. You can see this in the code sample within the PDFlib cookbook:table/starter_table use the bold text cells in for the header descriptions.
/* ---------- 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);
You can apply the font handle in the fittextline={} option. Of course you can also do an implicit load_font() by using the option fontname
and encoding
like:
$optlist = "fittextline={fontname=NotoSerif-Bold encoding=unicode fontsize=12" .
" position=center} margin=4 colspan=3 colwidth=" . $c1;
The starter_table.php sample is also included in the PDFlib 9 download package within the bind/php directory (or any other supported binding)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.