[英]AWS S3 PNG image not working with FPDF
在我的PHP FPDF脚本上
<?php
...
$mypdf->Image("http://s3-ap-southeast-1.amazonaws.com/mybucket/path/to/the/image/file.png", null, null, 150, 150);
...
?>
并导致错误。 但是,当我尝试执行相同的操作但使用S3上未托管的其他映像时,它可以工作。
S3不能与FPDF一起使用怎么办?
我遇到了同样的问题,在深入研究fpdf源代码后,我发现问题出在fopen()上 。 为了对S3图像使用此方法,您需要使用S3 Stream Wrapper 。 这需要适用于PHP的AWS开发工具包,或者如果确实愿意,也可以自己滚动。
我的代码看起来像这样
$credentials = new Aws\Credentials\Credentials('KEY','SECRET');
$client = new Aws\S3\S3Client([
'version'=>'latest',
'region' => 'REGION',
'credentials' => $credentials
]);
$client->registerStreamWrapper();
// Link to file
$url = 's3://bucket/key';
// add background image
$fpdf->Image($url, 0, 0, $fpdf->GetPageWidth(), $fpdf->GetPageHeight());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.