top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

PDF Editing in PHP?

0 votes
382 views
PDF Editing in PHP?
posted Aug 1, 2014 by Rahul Mahajan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

There is a free and easy to use PDF class to create PDF documents. It's called FPDF. In combination with FPDI ,it is even possible to edit PDF documents. The following code shows how to use FPDF and FPDI to fill an existing gift coupon with the user data.

require_once('fpdf.php');
require_once('fpdi.php');
$pdf = new FPDI();

$pdf->AddPage();

$pdf->setSourceFile('gift_coupon.pdf');
// import page 1
$tplIdx = $this->pdf->importPage(1);
//use the imported page and place it at point 0,0; calculate width and height
//automaticallay and ajust the page size to the size of the imported page
$this->pdf->useTemplate($tplIdx, 0, 0, 0, 0, true);

// now write some text above the imported page
$this->pdf->SetFont('Arial', '', '13');
$this->pdf->SetTextColor(0,0,0);
//set position in pdf document
$this->pdf->SetXY(20, 20);
//first parameter defines the line height
$this->pdf->Write(0, 'gift code');
//force the browser to download the output
$this->pdf->Output('gift_coupon_generated.pdf', 'D');

answer Aug 5, 2014 by Amanpreet Kaur
Similar Questions
+2 votes

Any pointer would be helpful?

0 votes

I'm looking into a good versatile PDF generator class/library to use with PHP 5? --- Preferably one which is maintained somewhat recently...

Mostly needed for basic pages, but I also have some longer reports (more than one 8.5" x 11" page) and it would be nice if the pdf was able to split it up without losing part of the font when crossing page boundaries etc...

0 votes

recently I have made a form code and attached modules to it. but soon after I have reached an error saying Notice: Undefined index: module in F:\website\webpage\gate.php on line 68

here is the line that was mentioned

   switch ($_GET["module"]) {
    case "settings":
      Include('settings.php');
      break;
    default:
      break;
   }

I am also mentioning the code in the that I showed up ib the link

<a class="nav-link" href="gate.php?module=settings"> Settings </a>

please rectify this error for me and sorry for any in trouble

...