gpt4 book ai didi

php - 使用 PHP 和 FPDF 插入图像

转载 作者:IT王子 更新时间:2023-10-28 23:51:06 26 4
gpt4 key购买 nike

我正在尝试插入图像,但不想指定 x 和 y 坐标。这可能吗?

$pdf->Image($image1, 5, 70, 33.78);

我希望能够指定大小 (33.78) 而不是 x 和 y,以便它根据内容移动。

$pdf->Write( 70, $reportTitle );
$pdf->Ln( 45 );
$pdf->SetFont( 'Arial', '', 12 );
$pdf->Write( 6, $reportSubtitle );

/**
Create product 1
**/
$pdf->Ln( 10 );
$pdf->SetFont( 'Arial', '', 12 );
$pdf->Write( 6, $prod1title );
$pdf->Ln( 30 );
$pdf->SetFont( 'Arial', '', 10 );
$pdf->Write( 5, $prod1sub );
$pdf->Ln( 30 );
$pdf->Image($image1, 5, 70, 33.78);

以上是我使用的代码。如果 $reportSubtitle 是两三行,它会把 $prod1title 和 $$prod1sub 往下推,而且不可避免地会在固定的图像下面。有没有办法让图像像产品标题和副标题一样被下推,同时仍然声明尺寸?

最佳答案

我想通了,实际上非常简单。

设置你的变量:

$image1 = "img/products/image1.jpg";

然后创建一个单元格,定位它,然后使用您在上面创建的变量,而不是设置图像的位置:

$this->Cell( 40, 40, $pdf->Image($image1, $pdf->GetX(), $pdf->GetY(), 33.78), 0, 0, 'L', false );

现在,如果周围的其他单元格移动,单元格将随着内容上下移动。

希望这对同一条船上的其他人有所帮助。

关于php - 使用 PHP 和 FPDF 插入图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3471441/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com