php - 如何在单元格 PHP FPDF 中推送图像?
问题描述
大家好,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();
?>
解决方案
在输出图像和单元格之前,移动计数器并测试所需的新页面。您尚未发布完整页面的外观,但看起来好像图像大到足以导致页面溢出,但您在输出之前不会移动到新页面。
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);
}
推荐阅读
- python - 如何在python中将xml(都柏林核心)转换为csv?
- algorithm - 在网格中找到最重的路径,如图形
- c - 在 C 中复制不佳的结构元素的地址
- css - 单击下拉列表中的任何链接后如何关闭仅 CSS 下拉菜单?
- websocket - WSO2 EI(企业集成商)6.5.0 websocket 将资源附加到 dispatchSequence 中的端点
- javascript - 在反应js中将数据传递给组件onClick
- c++ - 关于迭代器和n log n解决方案的一些问题
- c++ - 按钮单击时调用的 CreateWindowEx 失败
- rust - 使用特征作为幻像类型
- r - tPath:在 R 中的动态网络分析中,如何根据通过网络的时间对前向可达路径进行着色?