gpt4 book ai didi

php - 如何使用 FDI/FPDF 从 PDF 中删除文本

转载 作者:行者123 更新时间:2023-12-05 04:15:10 26 4
gpt4 key购买 nike

我想使用 FPDI/FPDF 在 php 中编辑 PDF。我想替换特定的文本。我尝试了很多解决方案,但他们没有给出预期的结果。所有人都在新位置写一些新文本。我想搜索一些文本并用新文本替换该文本。
这可能吗?如果是,请解释。
代码:

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

$pdf =& new FPDI();
$pdf->AddPage();


//Set the source PDF file
$pagecount = $pdf->setSourceFile("test.pdf");

//Import the first page of the file
$tpl = $pdf->importPage(1);
//Use this page as template
$pdf->useTemplate($tpl);



//Go vertical position
$pdf->SetY(15);
//Select Arial italic 8
$pdf->SetFont('Arial','I',8);
//Print centered cell with a text in it
$pdf->Cell(0, 10, "Hello World", 0, 0, 'C');

//want something like this
$pdf->replace("old_text","new_text");

$pdf->Output("my_modified_pdf.pdf", "F");

最佳答案

无法使用 FPDI 编辑 PDF 文档,也无法使用 FPDI 替换导入的 PDF 页面的文本。

关于php - 如何使用 FDI/FPDF 从 PDF 中删除文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33037429/

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