Background Color inside a cell is not changing in fpdf

大城市里の小女人 提交于 2020-05-23 12:56:04

问题


Im using fpdf to generate a pdf file for my reports and Im new to this. I want to change the fill color inside a cell but whenever I reloaded the page, nothing hapeens, It still the same white fill color. Here is my code :

<?php
   require("fpdf/fpdf.php");

   $pdf = new FPDF('P','pt','Letter');
   $pdf->SetFillColor(230,230,230);

   $pdf->SetTitle("Title Here");    
   $pdf -> AddPage();
   $pdf -> SetFont('Arial','',12); 

?>

What is wrong with my code? I followed the proper way of setting the fill color but nothing happens? Can anyone help me fix it? Thanks


回答1:


Tyr something like:

$pdf->setFillColor(230,230,230); 
$pdf->Cell(0,10,$text,0,1,'L',1); //your cell

Defines the color used for all filling operations (filled rectangles and cell backgrounds). It can be expressed in RGB components or gray scale. The method can be called before the first page is created and the value is retained from page to page.

Take a look to the FPDF manual




回答2:


mpdf->SetFillColor('RED');

Just set the seventh parameter equal to TRUE

$mpdf->WriteCell(38, 10, 'HELLO', 1, 0, 'C', TRUE);


来源:https://stackoverflow.com/questions/27894890/background-color-inside-a-cell-is-not-changing-in-fpdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!