2

I have an TCPDF file where i want to set 1 cell with fill-background color, and to change the text in that cell to Upper-Case and color to white

$pdf->SetFont($pdfFont, 'B', 10);
$pdf->SetFillColor(59,78,135);
$pdf->Cell(50, 6, Lang::trans('supportticketsclient'), 0, 1, 'L', true);

I know i have to add "strtoupper" for uppercase letters but don't know where, and SetTextColor or something similar to it, but when i set that

$pdf->SetTextColor(0,0,0);

My whole pdf color is changed.

Acidburns
  • 131
  • 3
  • 13

2 Answers2

3

you just need to use the same function to change the colour back to the original(or a new colour)

$pdf->SetFont($pdfFont, 'B', 10);
$pdf->SetFillColor(59,78,135);
$pdf->SetTextColor(0,0,0);
$pdf->Cell(50, 6, strtoupper(Lang::trans('supportticketsclient')), 0, 1, 'L', true);
$pdf->SetTextColor(255,255,255);//change back to black
  • Okey the color its okey now, but UpperCase its not working :( – Acidburns Nov 02 '15 at 00:22
  • what does `Lang::trans('supportticketsclient')` return? –  Nov 02 '15 at 00:24
  • Translated word "Client" <- that i wanted to be "CLIENT" – Acidburns Nov 02 '15 at 00:26
  • sure should work, but you could try `$txt=strtoupper(Lang::trans('supportticketsclient'));$pdf->Cell(50, 6,$txt, 0, 1, 'L', true);` –  Nov 02 '15 at 00:28
  • if that fails, `echo strtoupper(Lang::trans('supportticketsclient'));` see if that works. –  Nov 02 '15 at 00:30
  • It doesnt work either way... i guess i would have to change the word in php-translate file to CLIENT :) (but that way everywhere in the program client will be with capitalized letters) – Acidburns Nov 02 '15 at 00:33
  • you could, but should not have to, its weird it is not working. –  Nov 02 '15 at 00:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/93985/discussion-between-viktorg-and-dagon). – Acidburns Nov 02 '15 at 13:07
1

I have the same problem on changing the text in a cell to Upper-Case..

What I did was convert it on my query

$appName = $row['appFname']." ".$row['appMname']. " ".$row['appLname'];
$appNameUPPER = strtoupper($appName);

then I used that variable on my cell

$pdf->Cell(179,26,''.$appNameUPPER.'', 'B','', 'C', '','','','','','B');

then it works! Try converting it on your query~

It's my first time to answer here hope it works on you (^_^)/