php - 使用 PHP 将两个或多个 base64 代码合并到一个 PDF 中

标签 php pdf merge base64

我有两个或多个具有 PDF 格式的 base64 值的变量。 无论如何我可以合并所有变量并将它们变成一个 PDF,因为不可能通过 HTTP 下载超过 1 个 PDF。

非常感谢您的回答。

最佳答案

老问题,但我的解决方案。 我发现并使用了 http://www.fpdf.org/en/script/script94.php

从数据库中获取 base64 数据并创建临时文件,将名称保存在一个数组中。

$pdf = fopen ('../tmp/test'.$rowp['id'].'.pdf','w');
fwrite ($pdf,base64_decode($rowp['pdf']));
fclose ($pdf);
array_push($pdfs,'../tmp/test'.$rowp['id'].'.pdf');

然后对于数组中的名字

$merge->add($pdfs[$i]); //add next file
unlink($pdfs[$i]); //clear temp one

最终输出到浏览器

$merge->output();

关于php - 使用 PHP 将两个或多个 base64 代码合并到一个 PDF 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30579229/

相关文章:

python - 用python数据框中的列表替换python中的缺失值

PHP在XSLT1中注册了函数,如何用PHP返回XML片段?

php - htaccess url 重写为 .php

pdf - 如何在 iText 中获取 AcroField 修订的名称?

git - 使用 git-svn : Pull, merge 还是 rebase ?

git - 使用 Git 更新生产服务器

php - 无法为某些字段选择数据

PhpMyAdmin The session id is too long and Session object destruction failed 警告消息

pdf - 如何以编程方式编辑 PDF 文件?

codeigniter - 单击codeigniter中的下载按钮后将html转换为pdf