开发者社区> 问答> 正文

MySQL / FPDF:从MYSQL到FPDF的图像不在单元格中

我使用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();
?>

展开
收起
社区秘书 2019-12-04 13:51:08 638 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
搭建电商项目架构连接MySQL 立即下载
搭建4层电商项目架构,实战连接MySQL 立即下载
PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载

相关镜像