Sunday, April 5, 2009

Example Adobe PHP

Example:
SQL Database:
transaction_id (Primary key)
user_id
Datafields1..,...Datafields n


page.php
setcookie(...set your unique identifer);
location("Header: form.php");

form.php
Insert PDF and have an HTML submit pointed to process.php (Using Life cycle)

process.php
insert data into the SQL Table with 0 as the User ID.
Capture the Transaction ID.
Set it as a cookie.
setup a meta-refresh to point to finish.php

finish.php
Update the SQL table with the user ID which was set in Page.php under whatever cookie name.
Grade the Transaction ID from the cookie in Process.php
SQL Update command...Done.

You now have a way around the problem of not being able to add dynamic values to a pdf file.

I hope you find this methodology somewhat useful!
I spent hours googling for something similar, so I hope you found it before spending too much time searching!

I will be creating a more standardized version of this with a proper class structure and what not to assist people but generalizing this is going to be a pain...and im pretty lazy :P

anyway till next post. PC

Adode PDFs + PHP

Recently I have been doing a lot of PHP development. Integrating Adobe PDFs into websites for some corporate clients. Since they already have the PDF forms made, they wanted to have their end-users simply fill it in and submit to database.

This is a rather simple concept. I grabbed up the most recent version of the Adobe Suite which came with a nice program called Adobe Life Cycle ES. This allows you to add an HTML Submit button to the PDF form. Link the HTML Button to a PHP file that submits data and Done.

However this has limitations:
1) ...It is currently not possible to embed dynamic values into a PDF. Ie lets say you need to generate a PDF with a unique identifier in it...like a user id. You cant put it in the PDF.

Well thats kinda useless isnt it.

2) the HTTP Submit, does not submit any cookie values. Well this sort of makes sense...the HTTP Submit only submits the PDF Form and not the whole FORM page.

Cookies would have been useful to store data in...
I highly doubt that adobe will be supporting this feature. If we think about the PDF as a HTML page within an HTML page, the PDF does not have access to the browser's cookie storage (I think for various security reasons....) and therefor cannot actually do a page submit.

My Solution:
Yea its very hackish...but hey whatever works when your working with incomplete technology.

Sup

I decided to actually start a blog so I could start sharing some of the code I have come up with.

Anyway I write in PHP5/PHP4, C#, Java.

Ive been doing PHP development for 4 years. C#, 2 years and Java for about a year now.
C++/C development for 2 years as well, but since everything is moving web-based I tend to not code in C++ or C.

On this blog i will post some useful code examples that hopefully you will find useful.