如何设计我的Php(Pdf)
好的,我已经在下面复制了我的代码。 我想在php代码中应用pdf格式,我已经成功地完成了它的工作,但是我想给它一个样式,我怎样才能在我的pdf上应用样式。 我已经添加了一个表,但我希望行的背景颜色可以替换 更新~!!!!如何设计我的Php(Pdf),php,html,css,pdf,Php,Html,Css,Pdf,好的,我已经在下面复制了我的代码。 我想在php代码中应用pdf格式,我已经成功地完成了它的工作,但是我想给它一个样式,我怎样才能在我的pdf上应用样式。 我已经添加了一个表,但我希望行的背景颜色可以替换 更新~!!!! class PDF extends FPDF { function BasicTable($header) { //Header for($i=0;$i<10;$i++) { $this->SetTextColor(1)
class PDF extends FPDF
{
function BasicTable($header)
{
//Header
for($i=0;$i<10;$i++)
{
$this->SetTextColor(1);
$this->SetDrawColor(128,11,4);
$this->SetLineWidth(1.3);
$this->SetFont('','');
$this->SetFillColor(224,235,5);
foreach($header as $col)
$this->Cell(40,7,$col,1);
$this->Ln();
//Data
}
}
function FancyTable($header)
{
//Colors, line width and bold font
$this->SetTextColor(255,131,13);
$this->SetDrawColor(18,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//Header
$w=array(40,35,40,45);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
$this->Ln();
//Color and font restoration
$this->SetFillColor(124,25,255);
$this->SetTextColor(130);
}
}
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->SetTextColor(0,0,102);
$pdf->SetXY( 65 , 25 );
$pdf->Write(0, "Requisition Reports");
$pdf->Line(20 , 32 , 195 , 31);
$pdf->SetTextColor(0,0,10);
$pdf->SetFont('Arial','I',10);
$pdf->SetXY( 20 , 30 );
$pdf->Write(0, "Request ID");
$pdf->SetTextColor(0,0,10);
$pdf->SetFont('Arial','I',10);
$pdf->SetXY( 45, 30 );
$pdf->Write(0, "FOR :");
$pdf->SetTextColor(0,0,10);
$pdf->SetFont('Arial','I',10);
$pdf->SetXY( 70 , 30 );
$pdf->Write(0, "From :");
$pdf->SetTextColor(0,0,10);
$pdf->SetFont('Arial','I',10);
$pdf->SetXY( 95 , 30 );
$pdf->Write(0, "Date :");
$pdf->SetTextColor(0,0,10);
$pdf->SetFont('Arial','I',10);
$pdf->SetXY( 120, 30 );
$pdf->Write(0, "Item :");
$pdf->SetTextColor(0,0,10);
$pdf->SetFont('Arial','I',10);
$pdf->SetXY( 135, 30 );
$pdf->Write(0, "Description :");
$pdf->SetTextColor(0,0,10);
$pdf->SetFont('Arial','I',10);
$pdf->SetXY( 160, 30 );
$pdf->Write(0, "User");
$pdf->SetTextColor(0,0,10);
$pdf->SetFont('Arial','I',10);
$pdf->SetXY( 175, 30 );
$pdf->Write(0, "Status");
$querya=mysql_query("select * from request order by FIELD(Status,'done','pending');");
$b=35;
$ids=array();
$c=40;
while ($row = mysql_fetch_array($querya)) {
$forname=$row['for'];
$fromname=$row['from'];
$req=$row['request_id'];
$queryb=mysql_query("select name from entities where id=$forname;");
while ($row2 = mysql_fetch_assoc($queryb)) {
$forname=$row2['name'];
}
$queryc=mysql_query("select name from entities where id=$fromname;");
while ($row3 = mysql_fetch_assoc($queryc)) {
$fromname=$row3['name'];
}
$pdf->SetTextColor(124,12,10);
$pdf->SetXY( 30 , $b );
$pdf->Cell(0,5,$req,1);
$pdf->SetTextColor(124,12,10);
$pdf->SetXY( 45, $b );
$pdf->Cell(0,5,$forname);
$pdf->SetTextColor(124,12,10);
$pdf->SetXY( 70 , $b );
$pdf->Cell(0,5,$fromname);
$pdf->SetTextColor(124,12,10);
$pdf->SetXY( 95 , $b );
$pdf->Cell(0,5,$row['request_date']);
$pdf->SetTextColor(124,12,10);
$pdf->SetXY( 120 , $b );
$pdf->Cell(0,5,$row['item_name']);
$pdf->SetTextColor(124,12,10);
$pdf->SetXY( 135 , $b );
$pdf->Cell(0,5,$row['description']);
$pdf->SetTextColor(124,12,10);
$pdf->SetXY( 165 , $b );
$pdf->Cell(0,5,$row['user']);
$pdf->SetTextColor(124,12,10);
$pdf->SetXY( 175 , $b );
$pdf->Cell(0,5,$row['status']);
//if($row['status']=="done")
//{
//$id=$row['request_id'];
//$queryd=mysql_query("select * from issue where request_id=$id;");
//while ($row4 = mysql_fetch_assoc($queryd))
//{
//$iss_date=$row4['issue_date'];
//$pdf->SetTextColor(11,11,120);
//$pdf->SetXY( 30, $c );
//$pdf->Write(0, "Issue Date:");
//$pdf->SetXY( 50 , $c );
//$pdf->Write(0, $row4['issue_date']);
//$pdf->SetTextColor(11,11,120);
//$pdf->SetXY( 75, $c );
//$pdf->Write(0, "Description:");
//$pdf->SetXY( 95 , $c );
//$pdf->Write(0, $row4['description']);
//$pdf->SetTextColor(11,11,120);
//$pdf->SetXY( 125, $c );
//$pdf->Write(0, "User:");
//$pdf->SetXY( 140 , $c );
//$pdf->Write(0, $row4['user']);
//}
//$header=array();
//$header=array($row4['issue_date'],$row4['description'],$row4['user']);
//}
$b+=15;
$c+=15;
}
$pdf->Output();
?>
你想应用什么类型的样式?就像我需要一个表格,表格中的行有不同的颜色。我想给标签不同的颜色,使它看起来有吸引力,很好,它的工作很好,但我想应用的风格,只有像你擦太多了。创建要设置样式的行的循环在哪里?我们需要查看代码循环。请把它放回去。当您回复用户的评论时,请始终放置@username,以确保通知他们您回复了他们的评论。回答我的评论?在你的评论中包括@Kuya。然后系统会通知我你已经回复了。谢谢。@Kuya我已经更新了我的代码,请参见