簡體   English   中英

AWS S3 PNG圖像不適用於FPDF

[英]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 這需要適用於PHPAWS開發工具包,或者如果確實願意,也可以自己滾動。

我的代碼看起來像這樣

$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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM