Link to home
Start Free TrialLog in
Avatar of Matthew_Way
Matthew_Way

asked on

Reading PDF form data directly from file.

I'm using TCPDF to create PDF forms.
The form creation process is working well, the problem is collecting them.

Let me explain the situation.

We have a PHP application on our intranet, which creates a PDF form and Emails it to our customers for completion.
They confirm / update details on the form and then Email it back to us.
Then we want to 'file upload' the PDF to the server, a full copy of the PDF ( data and form ) are saved for our records.
Then we need to strip out the form data and prompt the operator to confirm details and write the update to the MySQL database.

While the 'submit to url' function of the PDF form would be simple it dosn't work for us for the following reasons.

#1 Our customers don't have access to our intranet.
#2 We want to keep a record of the completed PDF

Our own operators can't use the submit because the PDF submission by passes the user authentication process.

Does anyone know of a PHP class that can pull form data directly from a PDF file.

I want a pure PHP solution.

Avatar of innotionent
innotionent

I think you are going about this the wrong way.
If I'm not mistaken there should be a way to get a PDF to submit it's form contents to a server just by clicking a button on the pdf itself. Trying to read the data from the pdf is just adding another layer of complexity. K.I.S.S.

tcpdf is a bit light on documentation. However there are some examples.

here is the php code.
http://www.tecnick.com/pagefiles/tcpdf/example_014.phps

Here is the finished pdf with form submission.
http://www.tecnick.com/pagefiles/tcpdf/example_014.pdf

I hope that this helps you out.
Avatar of Matthew_Way

ASKER

I have no problem using TCPDF to submit a form, and I have already R.T.F.M.

A Couple of points.
1. The customers who are filling the forms are not connected to our network.
2. We want to keep a copy of the completed PDF forms.
3. Only some of our operators will be allowed to upload forms.
4. The operator needs to be authenticated before they upload.
5. The operator will need to approve / allow particular field updates on a case by case basis.

$pdf->Button('submit', 30, 10, 'Submit', array('S'=>'SubmitForm', 'F'=>'http://ourhostname.intranet/input_form.php', 'Flags'=>array('ExportFormat')), array('lineWidth'=>2, 'borderStyle'=>'beveled', 'fillColor'=>array(128, 196, 255), 'strokeColor'=>array(64, 64, 64)));

Open in new window

1. I would submit over https if possible

2. once the data is uploaded. recreate the pdf for archiving. that way things would be seemless.

3 & 4. embed authentication into the pdf

5. ???

I'm going to look into also embedding metadata into pdf's. I just ran into something yesterday and I will read up on it a little more.
Oh and before I forget also and maybe someone else can chime in on this. I don't think users , with adobe reader, have the ability to change and save a pdf with forms.
I'm about 75% sure about this. I have run into issues in the past with this.
After looking around the net I was able to find the xpdf package that has a feature to read pdf files.

http://davidwalsh.name/read-pdf-doc-file-php

This may or may not work. Let me know.
$content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -'); //dash at the end to output content

Open in new window

I've been using Acrobat Professional version 7 my self and can save filled in PDF's

I installed Acrobat 7 Reader on another machine and your correct you can not save PDF's.
There is a message in the reader.
"You cannot save data typed into this form. Please print your completed form if you would like a copy for your records."

I think that really sucks !

I would rather not have our inhouse application connected to the internet if I can avoid it!
Found this info on TCPDF / Saving a form.

The Adobe FAQ does say Reader can save files provided the "local save" capability is turned on with "Adobe Livecycle designer ES"

The signing process has been implemented on the latest TCPDF release but unfortunately it doesn't work because requires the Adobe private key!
So, seems that only using official Adobe products you can enable this feature on.

http://sourceforge.net/projects/tcpdf/forums/forum/435310/topic/2809680
ASKER CERTIFIED SOLUTION
Avatar of innotionent
innotionent

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Far from ideal, but that's Adobe for you!