3

I Want to edit PDF in php using FPDI/FPDF.I want to replace particular text.I have try many solution but they are not giving the desired result.All are writing some new text in new position. I want to search some text and replace that text with a new text.
Is This Possible?If yes please explain.
Code:

    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");
Anand Singh
  • 2,343
  • 1
  • 22
  • 34

1 Answers1

3

It is not possible to edit a PDF document with FPDI and also it is not possible to replace text of an imported PDF page with FPDI.

Jan Slabon
  • 4,736
  • 2
  • 14
  • 29
  • 4
    Thanks for you answer,,Is there is any other way in PHP by which we can do pdf editing..?? – Anand Singh Oct 12 '15 at 06:50
  • @Setasign is there other solution to edit text? or get the coords of a specif string in pdf? – Haseeb Zulfiqar May 19 '16 at 10:36
  • @Mian Haseeb We only offer a [solution](https://www.setasign.com/products/setapdf-extractor/details/) to extract text and its positions but I'm not aware of any solution that would allow you to replace text, sorry. – Jan Slabon May 21 '16 at 08:38