Reputation: 67
I have a table and I want to give it a background color with light transparency. I know we have the option "fillcolor" but there we can only use something like rgb (means no use of rgba) and color codes which looks like this: fillcolor={rgba 0.9 0.5 0}
or fillcolor={#ffed00}
.
So how can I make the background more transparent?
Upvotes: 0
Views: 580
Reputation: 2185
You can implement this in PDFlib if you create a GState with "opacityfill" and then output that when placing the table. In a simple code example this looks like this:
$gstate= $p->create_gstate("opacityfill=.5");
$tbl = $p->add_table_cell($tbl, 1, 1,
"Text",
"fittextline={fontname=NotoSerif-Regular encoding=unicode " +
"fontsize=12} colwidth=100 rowheight=30");
$result = $p->fit_table($tbl, 50, 50, 500, 800, "fill={ {area=table fillcolor={red} } } gstate=" . $gstate);
This code fragment then leads to the following output if you then place the table on a colored background (such as an image), for example:
Please also refer to chapter 7.2 "Graphics State" in the PDFlib API Reference for full details on create_gstate(). Maybe also interesting, if you want to have the effect only on one cell, you can also define the decoration of a cell using Matchbox and you can specify a GState with it. (see PDFlib 9.3.1 Tutorial, chapter 9.4 "Matchboxes" for further details)
Upvotes: 2