【发布时间】:2016-01-07 08:28:16
【问题描述】:
我想使用 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");
【问题讨论】:
-
什么是
=&?没见过。 -
检查这个 ....stackoverflow.com/q/5930177/3143384 如果你有我的问题,请说..它很紧急。
-
有趣...你读过answer吗?你指的是一个类而不是一个变量。实际上,您指的是新对象的实例化,这对我来说没有意义。你能解释一下它的目的吗?
-
我还没有任何答案,因为我仍然需要了解您的代码是如何工作的。
-
其实它的类的对象也是一个变量..正确