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
https://forums.phpfreaks.com/topic/102585-solved-pdf-editing-without-pdflib/
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

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.