【问题标题】:How can I push the image in the cell PHP FPDF?如何在单元格 PHP FPDF 中推送图像?
【发布时间】:2020-06-10 12:19:08
【问题描述】:

大家好,stackoverflow 中的每一个人。我今天整天都在努力解决这个问题。正如您在下面的图像中看到的,二维码不在列中。这发生在最后一行的所有页面上。我还将附上我的代码。请检查我的代码是否有问题。计数器将显示一行三列相同的数据。

<?php
include('../Connection/connection.php');
require('../FPDF/fpdf.php');


$QueryCustomer = "SELECT cus_name, cus_qr FROM tbl_customer WHERE cus_status = 1 AND cus_type = 1";
$ResultQueryCustomer = mysqli_query($con,$QueryCustomer);
$RowQueryCustomer = mysqli_num_rows($ResultQueryCustomer);

$QueryWebConfig = "SELECT * FROM tbl_web_config";
$ResultQueryWebConfig = mysqli_query($con,$QueryWebConfig);
$RowQueryWebConfig = mysqli_num_rows($ResultQueryWebConfig);
$ResQueryWebConfig = mysqli_fetch_array($ResultQueryWebConfig);



$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',8);    
$counter = 0;

while($ResQueryCustomer = mysqli_fetch_array($ResultQueryCustomer)){ 
    $pdf->Image("../CustomerQr/".$ResQueryCustomer['cus_qr'].".png", $pdf->GetX(), $pdf->GetY(), 40);
    $pdf->Cell( 65, 80,$ResQueryCustomer['cus_name'],1);

    $counter++;
    if($counter % 3 == 0) 
    {
      $pdf->Ln();

    }

}
$pdf->Output();
?>

【问题讨论】:

    标签: php fpdf


    【解决方案1】:

    在输出图像和单元格之前,移动计数器并测试所需的新页面。您还没有发布整页的样子,但看起来好像图像大到足以导致页面溢出,但在它已经输出之前您不会移动到新页面。

    while($ResQueryCustomer = mysqli_fetch_array($ResultQueryCustomer)){ 
        $counter++;
        if($counter % 3 == 0) {
          $pdf->Ln();
        }
        $pdf->Image("../CustomerQr/".$ResQueryCustomer['cus_qr'].".png", $pdf->GetX(), $pdf->GetY(), 40);
        $pdf->Cell( 65, 80,$ResQueryCustomer['cus_name'],1);
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-09-29
      • 1970-01-01
      • 2015-11-13
      • 2016-04-04
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多