gpt4 book ai didi

php - 在 PHP 中以编程方式编辑 PDF 文件

转载 作者:行者123 更新时间:2023-12-02 09:27:32 27 4
gpt4 key购买 nike

背景信息:我有一个项目,使用 PHP 从给定的 PDF 文件动态生成自定义 PDF。我需要它做的就是替换字符串,例如在“template.pdf”中搜索“{Address}”,替换为“街道名称”。

我已经看到了 fpdf/pdfi/dompdf 等的链接,但找不到任何可以使用的有用示例代码:s。任何帮助/指示将不胜感激。

最佳答案

fpdf 非常棒,但您需要使用其他东西来导入现有的 PDF,请参见下文。

http://www.setasign.de/products/pdf-php-solutions/fpdi/

require_once('fpdf.php');
require_once('fpdi.php');

$pdf =& new FPDI();

$pagecount = $pdf->setSourceFile('TestDoc.pdf');
$tplidx = $pdf->importPage(1, '/MediaBox');

$pdf->addPage();
$pdf->useTemplate($tplidx, 10, 10, 90);

$pdf->Output('newpdf.pdf', 'D');

关于php - 在 PHP 中以编程方式编辑 PDF 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1700484/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com