我使用FPDF从PHP MySQL生成报告到PDF。在MySQL中,它还以BLOB格式存储图像。我的PDF看起来像表格,因此,我使用单元格来完成。
关于BLOB,我已经成功地将其从MySQL显示为PDF。问题是,该图像未显示在单元格中。我尝试找到解决方案,但仍然无法解决。以下是我当前的FPDF代码。
require('mem_image.php');
require_once "../../config/config.php";
require_once "../../config/check.php";
$email = $_SESSION['login_user'];
$team = $_SESSION['team'];
$pdf = new PDF_MemImage();
$pdf->AddPage();
$pdf->Cell(10,7,'',0,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(0,10,'Project Team Overtime Report',1,1,"C");
$pdf->SetFont('Arial','',10);
$pdf->Cell(20,10,'Team:',1,0);
$pdf->SetFont('Arial','B',11);
$user2 = mysqli_query($conn, "SELECT * FROM users WHERE email = '$email'");
while ($row = mysqli_fetch_array($user2)){
$pdf->Cell(170,10,$row['fullname'],1,1);
}
$pdf->SetFont('Arial','',10);
$pdf->Cell(0,10,'Workers Name:',1,1,"C");
$pdf->SetFont('Arial','B',10);
$pdf->Cell(20,7,'Badge ID',1,0);
$pdf->Cell(170,7,'Fullname',1,1);
$pdf->SetFont('Arial','',10);
$user = mysqli_query($conn, "SELECT * FROM users INNER JOIN team on users.team_id = team.team_id WHERE users.team_id = '$team' AND (users.roles_id = 3 OR users.roles_id = 4)");
while ($row = mysqli_fetch_array($user)){
$pdf->Cell(20,7,$row['badgeid'],1,0);
$pdf->Cell(170,7,$row['fullname'],1,1);
}
$pdf->Cell(190,5,'',0,1);
$pdf->Cell(190,7,'The Report',0,1,'C');
$pdf->Cell(190,5,'',0,1);
$pdf->SetFont('Arial','B',10);
$user3 = mysqli_query($conn, "SELECT * FROM report LEFT JOIN users ON report.badgeid = users.badgeid LEFT JOIN team ON team.team_id = users.team_id
WHERE team.team_id = '$team' AND report_date BETWEEN '".$_GET["from"]."' AND '".$_GET["to"]."' ORDER BY report.report_date DESC");
while ($row = mysqli_fetch_array($user3)){
$pdf->Cell(20,7,'Date:',1,0);
$pdf->Cell(75,7,date('d-m-Y',strtotime($row['report_date'])),1,0);
$pdf->Cell(20,7,'Time:',1,0);
$pdf->Cell(38,7,"From: ".date('H:i',strtotime($row['ot_start'])),1,0);
$pdf->Cell(37,7,"To: ".date('H:i',strtotime($row['ot_end'])),1,1);
$pdf->Cell(95,7,'Before',1,0,'C');
$pdf->Cell(95,7,'After',1,1, 'C');
$photo_before = $row['photo_before'];
$photo_after = $row['photo_after'];
$pdf->Cell( 95, 50, $pdf->MemImage(base64_decode($photo_before), $pdf->GetX(100), $pdf->GetY(100), 90,45,'C'), 1, 0, false );
$pdf->Cell( 95, 50, $pdf->MemImage(base64_decode($photo_after), $pdf->GetX(100), $pdf->GetY(100), 90,45,'C'), 1, 1, false );
$pdf->Cell(95,7,$row['time_photo_before'],1,0, 'C');
$pdf->Cell(95,7,$row['time_photo_after'],1,1, 'C');
$pdf->SetFillColor(216,214,214);
$pdf->Cell(0,5,'',1,1,"C", true);
}
$pdf->Output();
?>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。