我想添加一个 'imagebox' 一个包含图像的框,并裁剪超出此框之外的图像值。像这样的东西:
如果可能的话,我不确定如何做到这一点。
实际上,您可以使用 Clipping 来做到这一点。下面的行将显示 200X300 的照片:
$pdf->Image('photo.JPG', 100, 100, 200, 300, '', true, '', false, 300);
要剪辑它,您需要:
$pdf->StartTransform();
$pdf->Rect(100, 100, 200, 300, 'CNZ'); //Clipping mask (CNZ style makes your day)
$pdf->Image('photo.JPG', 50, 50, 300, 400, '', true, '', false, 300);
//this would actually cut off a 50 units a in each direction.
$pdf->StopTransform();
您可以使用 php 裁剪图像,将其存储为 temp_file 并将其传递给 tcpfd,然后在完成 pdf 的呈现后将其删除。另一种选择是使用 html/css 在图像上放置一个 html 元素,但我们都知道 tcpdf 对 css 了解不多,所以我不知道它是否可以工作。