如何使用 FPDI/FPDF 从 PDF 中删除文本
How to delete text from PDF using FPDI/ FPDF
我想使用 FPDI/FPDF 在 php 中编辑 PDF。我想替换特定的 text.I 已经尝试了很多解决方案,但他们没有提供所需的 result.All在新位置写一些新文本。我想搜索一些文本并用新文本替换该文本。
这可能吗?如果是,请解释。
代码:
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 页面的文本。
我想使用 FPDI/FPDF 在 php 中编辑 PDF。我想替换特定的 text.I 已经尝试了很多解决方案,但他们没有提供所需的 result.All在新位置写一些新文本。我想搜索一些文本并用新文本替换该文本。
这可能吗?如果是,请解释。
代码:
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 页面的文本。