Man*_*h C 3 php pdf codeigniter fpdi
我正在使用 FPDI 库将多个 pdf 文件合并为一个,
遵循此文档https://manuals.setasign.com/fpdi-manual/v2/the-fpdi-class/
我试过如下,
use \setasign\Fpdi\Fpdi;
use \setasign\Fpdi\PdfParser\StreamReader;
function merge()
{
$file = fopen('https://path/to/s3/file','rb');
$pdf = new Fpdi();
$pdf->AddPage();
$pdf->setSourceFile(new StreamReader($file));
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 10, 10, 100);
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');
$pdf->Output();
}
Run Code Online (Sandbox Code Playgroud)
当尝试在 streamReader 中传递 url 时,我得到Given stream is not seekable。
如何将 s3 文件传递给流阅读器并合并它。
HTTP 流包装器不支持搜索。
您必须将存储桶下载到临时文件或变量。一个简单的file_get_contents()应该这样做:
$fileContent = file_get_contents('https://path/to/s3/file','rb');
// ...
$pdf->setSourceFile(StreamReader::createByString($fileContent));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3848 次 |
| 最近记录: |