title: PDFlib - controlling background and opacity of text color, text background and text stroke
body: <p>I'm trying to set separate values of background and opacity of text color, text background and text stroke (outline).</p>
  
  <p>Code below</p>
  
  <pre class="lang-php prettyprint-override"><code>$p-&gt;save();
  $p-&gt;setfont($font, 240);
  $p-&gt;set_gstate($p-&gt;create_gstate('opacityfill=1 opacitystroke=1')); // Both fill and stroke are opaque
  $p-&gt;set_graphics_option('fillcolor={rgb 0.075 0.973 0.024} strokecolor={rgb 0 0 1}');
  $p-&gt;fit_textline('QfjIL', 30, 30, 'matchbox={boxheight={88% 24.5%} borderwidth=0 round=0 fillcolor={rgb 1 1 0}} charspacing=0 textrendering=2 strokewidth=10 position={left top}');
  $p-&gt;restore();
  </code></pre>
  
  <p>results in:</p>
  
  <p><a href="https://i.stack.imgur.com/tGfYj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tGfYj.png" alt="enter image description here"></a></p>
  
  <p>Yellow background, blue letter stroke and green letter fill are opaque - as expected.</p>
  
  <p>Adding opacity for fill and stroke to <code>gstate</code> as:</p>
  
  <pre class="lang-php prettyprint-override"><code>$p-&gt;save();
  $p-&gt;setfont($font, 240);
  $p-&gt;set_gstate($p-&gt;create_gstate('opacityfill=0.3 opacitystroke=0.3'));
  $p-&gt;set_graphics_option('fillcolor={rgb 0.075 0.973 0.024} strokecolor={rgb 0 0 1}');
  $p-&gt;fit_textline('QfjIL', 30, 30, 'matchbox={boxheight={88% 24.5%} borderwidth=0 round=0 fillcolor={rgb 1 1 0}} charspacing=0 textrendering=2 strokewidth=10 position={left top}');
  $p-&gt;restore();
  </code></pre>
  
  <p>results in ALL OF background, fill and stroke using the same opacity:</p>
  
  <p><a href="https://i.stack.imgur.com/lcMBT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lcMBT.png" alt="enter image description here"></a></p>
  
  <p><strong>Question</strong>:</p>
  
  <p>How can I control separately text background opacity (yellow), letter stroke opacity (blue) and letter fill opacity (green)?</p>