Pdf

Hello

I have a template PDF file which I want to be used by my page when i click a submit button. I basically want some information to be added to a pdf file.

If I have the pdf file already, how can I get some other data, from a database to be appended ontop of the pdf so a user can either save or print the newly created pdf?

Thanks

Neil

Take a peek at fpdf. It worked well for me on an old project with a similar requirement.

See http://www.setasign.de/products/pdf-php-solutions/fpdi/ for an add on to FPDF that allows you to import an existing PDF to edit.

Thanks. I will check those both out this evening when i continue with this project

Hey, Been trying to get this to work and have the following script:

<?php
require_once('includes/fpdf.php');
require_once('includes/fpdi.php');

$sname = $_GET['sname'];

$pdf =& new FPDI();
$pdf->AddPage();
$pdf->setSourceFile('includes/invoice_template.pdf');
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 10, 10, 100);  
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,$sname);
$pdf->Output('newpdf.pdf');
?>

But when run I get the following errors:

Deprecated: Assigning the return value of new by reference is deprecated in D:\Files\wamp\www\Geoff Invoices\make_invoice.php on line 7

Warning: require_once(fpdf_tpl.php) [function.require-once]: failed to open stream: No such file or directory in D:\Files\wamp\www\Geoff Invoices\includes\fpdi.php on line 27

Fatal error: require_once() [function.require]: Failed opening required ‘fpdf_tpl.php’ (include_path=‘.;C:\php5\pear’) in D:\Files\wamp\www\Geoff Invoices\includes\fpdi.php on line 27

Any ideas?

I really need to get this working as quickly as possible.

Thanks

Neil

remove the ampersand from the following line…

$pdf =& new FPDI();

Also check your paths of the included files

Still get these errors:

Warning: require_once(fpdf_tpl.php) [function.require-once]: failed to open stream: No such file or directory in D:\Files\wamp\www\Geoff Invoices\includes\fpdi.php on line 27

Fatal error: require_once() [function.require]: Failed opening required ‘fpdf_tpl.php’ (include_path=‘.;C:\php5\pear’) in D:\Files\wamp\www\Geoff Invoices\includes\fpdi.php on line 27

take the & out of this line:


$pdf =& new FPDI();


and check the paths to the includes are right

the includes do look to be fine. I can’t locate the files the errors are on about though but includes to fpdf.php and fpdi.php are fine

looks like the fpdf file needs a template to work from that should have been included in your download.

google for the _tpl file and drop it into the same folder as fdpf.php

Ok, I located that file and placed it in the same folder and now get the following error:

FPDF error: Unable to find xref table.

did you download the full fpdf package form fpdf.org?

Yes, I extracted the folder from the zip file and copied all files into my includes folder which i where i included them from.

Is this not correct?

yep thats perfect which is why its a bit off that its narfed up!

I have just tried the basic tutorial and it works fine. Have you tried them?

Just found this page with some information about the error:

http://www.vankouteren.eu/blog/2009/07/fpdf-error-unable-to-find-xref-table/

It looks like it could be an issue with my PDF file itself. Any ideas on how I can sort it out?

email the file over to me if you want and I will run it on my server.
will PM you.

yup its the original pdf and the way that it was saved.
I dropped yours into foxit reader, resaved it and it worked fine.

If you remake the pdf and try it again or resave it in Acrobat or wherever it should work.

Hmmm, I opened and resaved it via foxit reader and get the following error:

FPDF error: This document (includes/invoice_template.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI.

I just tried a completely different pdf file which worked perfectly, but it’s just the one I need to use that I cannot get to work in any way I try.

Neil

Try using a different pdf class, if something is that tempermental I wouldnt want it going live.

You probably hit the nail on the head with the word “free” … you tend to get what you pay for (unless you do it yourself).