Hallo,
Leider ist das FPDF Forum wohl tot. Hilfe bekomme ich jedenfalls keine.
Ich will in FPFD (mein Sorgenkind) die Farben für Schriften Rahmen und Füllflächen aus der DB definieren.
[PHP] $this->SetTextColor(255,0,0]); //zB Rote Schrift direkt definiert
$this->SetFont(‚Arial‘,‚B‘,‚16‘);
$this->SetXY(25, 10); // xy linksoben der (folgenden)Cell
$this->Cell(165, 10, $this->twArrRechnungsdaten[‚firmaNameZeile01‘], 0, 1, ‚R‘);[/PHP]
Stattdessen will ich:
[PHP] $this->SetTextColor(hex2dec($hex)); //$hex aus DB
$this->SetFont(‚Arial‘,‚B‘,‚16‘);
$this->SetXY(25, 10); // xy linksoben der (folgenden)Cell
$this->Cell(165, 10, $this->twArrRechnungsdaten[‚firmaNameZeile01‘], 0, 1, ‚R‘);[/PHP]
Die function geht…
[PHP]function hex2dec($hex)
{
$color = str_replace(„#“, „“, $hex);
$ret = array(
„r“ => hexdec(substr($color, 0, 2)),
„g“ => hexdec(substr($color, 2, 2)),
„b“ => hexdec(substr($color, 4, 2))
);
return $ret[„r“].", „.$ret[„g“].“, ".$ret[„b“];
} [/PHP]
So wird aber keine Textfarbe definiert und wird mal schwarz und mal garnicht gedruckt.
Nächster Versuch war:
[PHP]
$farbe=explode(„.“, hex2dec($hex));
$this->SetTextColor($farbe[0], $farbe[1], $farbe[2], );
$this->SetFont(‚Arial‘,‚B‘,‚16‘);
$this->SetXY(25, 10); // xy linksoben der (folgenden)Cell
$this->Cell(165, 10, $this->twArrRechnungsdaten[‚firmaNameZeile01‘], 0, 1, ‚R‘);[/PHP]
Aber da hat FPDF nur errors ausgespuckt…
Hier die entsprechende FPDF Funktion
[PHP]function SetTextColor($r, $g=null, $b=null)
{
//Set color for text
if(($r==0 && $g==0 && $b==0) || $g===null)
$this->TextColor=sprintf(‚%.3F g‘,$r/255);
else
$this->TextColor=sprintf(‚%.3F %.3F %.3F rg‘,$r/255,$g/255,$b/255);
$this->ColorFlag=($this->FillColor!=$this->TextColor);
}[/PHP]