Jump to content

[SOLVED] PDF Editing Without PDFLib


Pino

Recommended Posts

Hi All,

 

I have some template PDF's and I need to insert text values on the fly in PHP. Now I've been looking at http://www.ros.co.nz/pdf/ and its great for creating new PDF's. However I need the ability to edit a template and insert text (Of any font) at a set position. Did I miss something in the link above or is there another way? I cant warrant the $999 for PdfLib.

 

Just to add this is PHP5

 

Kind Regards

Link to comment
Share on other sites

Looks like it will do the trick, however when installing I get the following errors

 


Warning: FPDF::include(helvetica.php) [function.FPDF-include]: failed to open stream: No such file or directory in C:\xampp\php\PEAR\fpdf.php on line 550

Warning: FPDF::include() [function.include]: Failed opening 'helvetica.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\php\PEAR\fpdf.php on line 550
FPDF error: Could not include font metric file

Link to comment
Share on other sites

I've resolved it. On my local copy for some reason the fpdf class was in the pear directory and when the code referanced this it went there. If I make sure the fpdf class is in the same directory it works fine.

Link to comment
Share on other sites

Ok thanks for the help so far. I've got the classes working ok now. However I have one question.

 

My overall aim is to take a template PDF 'copy it' add some text at x/y then save the new one.

 

require_once('fpdi.php');

// initiate FPDI
$pdf =& new FPDI();
// add a page
$pdf->AddPage();
// set the sourcefile
$pdf->setSourceFile('test.pdf');
// import page 1
$tplIdx = $pdf->importPage(1);

$pdf->useTemplate($tplIdx, 0, 0, 60,90);

// now write some text above the imported page
$pdf->SetFont('Arial');
$pdf->SetTextColor(255,0,0);
$pdf->SetXY(25, 25);
$pdf->Write(0, "This is just a simple text");

$pdf->Output('newpdf.pdf', 'D');

 

This works well, however the origional PDF is 2.36x3.54 Inch the one that is produced from the template is massive. Any suggestions on how I can keep the size the same? I've tried to specify the size in MM (60x90)

 

useTemplate($tplIdx, 0, 0, 60,90);

 

Has no real effect.

 

Thanks Again

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.