Menu

Change color of <hr />

Help
kknoer
2009-02-03
2012-10-09
  • kknoer

    kknoer - 2009-02-03

    I was just wondering if anyone knew how to change the color of the <hr /> tag in TCPDF?

    I have tried tampering with the code and have come up with no solution.

     
    • Álvaro G. Vicario

      This is the piece of code where <hr> is generated:

                  case 'hr': {
                      $this-&gt;addHTMLVertSpace(1, $cell, '', $firstorlast, $tag['value'], false);
                      $this-&gt;htmlvspace = 0;
                      $wtmp = $this-&gt;w - $this-&gt;lMargin - $this-&gt;rMargin;
                      if ((isset($tag['attribute']['width'])) AND ($tag['attribute']['width'] != '')) {
                          $hrWidth = $this-&gt;getHTMLUnitToPoints($tag['attribute']['width'], $wtmp, 'px');
                      } else {
                          $hrWidth = $wtmp;
                      }
                      $x = $this-&gt;GetX();
                      $y = $this-&gt;GetY();
                      $prevlinewidth = $this-&gt;GetLineWidth();
                      $this-&gt;Line($x, $y, $x + $hrWidth, $y);
                      $this-&gt;SetLineWidth($prevlinewidth);
                      $this-&gt;addHTMLVertSpace(1, $cell, '', !isset($dom[($key + 1)]), $tag['value'], false);
                      break;
                  }
      

      You'd just need to change the draw colour before drawing the l¡ne (taking care of storing the previous value and restoring it later, just as this code does with line width).

       

Log in to post a comment.

MongoDB Logo MongoDB