Page 1 of 1

Mysql -> PHP -> PDF Mailmerge Challange!!

Posted: Sat Jan 08, 2005 9:01 pm
by abshaw
I have finally given up researching and now i am going to put exactly what my scinario is, and i am in need of help despratly.

I have a website working fully in php with mysql as the back end, no problems. Now what my boss wants done is have an accord form (some insurance kind of deal) available in pdf format, to be placed on the webserver (hosting it outside the company/ external so dont have access to the linux or apache configuration or installation) and then be auto filled/ mail merged for the clients only.

here are the steps
1. client comes to a php based form. hits submit (no problem)
2. all the data goes into mysql database (no problem)
3. after writing the data to the database, i can aquire the unique id auto assigned for this client.

big problem starts here :(

for the forementioned client id
4. open the single pdf form located on the server.
5. pick the corressponding fields from the mysql db and fill in the pdf document.
6. open this pdf document on the clients browser (we dont need to save the respective pdf document as the data is already in mysql).

this has been my challenge for about 7 days now (not to mention with almost no sleep). Is there anyone out there who has my sleeping pill :D

Posted: Sat Jan 08, 2005 9:06 pm
by markl999
I'd start with http://www.fpdf.org/ as it requires no extensions etc to be loaded on the host.
As for modifying an existing pdf template i'm not sure about ... whenever i've done a similar thing in the past i've just had some PHP code to create the PDF from scratch having set title/areas etc and just changing the unique/user info as required. I suppose this last bit depends on how complex the template is and how hard it would be to generate it from scratch using just PHP.

Posted: Sat Jan 08, 2005 9:31 pm
by abshaw
thanks for the quick reply,

but creating the form from scratch is not an option, this pdf doc is 7 pages long with a lot of fine print, lines (horizontal and vertical) check boxes, zones .... bottom line quite a complex doc to be created on the fly, thus the only option the came to my mind is filling in the fields on the form as read only (for the client) and be done with it.

:? 8O

Posted: Sat Jan 08, 2005 9:35 pm
by markl999
Ah, that's the killer then ;)
I've not been able to find a decent solution to modifying existing PDF templates/files with PHP....yet.

Posted: Sat Jan 08, 2005 9:38 pm
by abshaw
here are some of the forms that will be used for this project

http://www.consumerarts.com/atlatlforms ... rms/41.pdf
http://www.consumerarts.com/atlatlforms ... rms/25.pdf
http://www.consumerarts.com/atlatlforms ... rms/72.pdf

i hope this helps give the idea of what i am trying to achive. :wink:

Posted: Sat Jan 08, 2005 9:42 pm
by feyd
maybe having php write the postscript needed to generate it, then pass that to a pdf creation tool?

Posted: Sat Jan 08, 2005 9:44 pm
by abshaw
i am sorry feyd,

i am a novice when it comes to pdf creation, can you please guide me in the right direction and if possible please explain what it means to "write the postscript" and how to do that.

Posted: Sat Jan 08, 2005 9:55 pm
by feyd
I don't know for sure, because I haven't had to deal with creating pdf's via php, but I have through several other media..

[google]+postscript +what[/google] for an explanation of what postscript is..

I know there are *nix command line tools that will render a .ps/.eps file into a .pdf... [google]GhostScript[/google] comes to mind.

Posted: Sun Jan 09, 2005 6:49 am
by abshaw
does any one know enough about the "FDF" and its funtionality, would that help in achieving what i want done. if so how ?

Posted: Sun Jan 09, 2005 9:35 am
by feyd
from a quick look, fpdf has setting of xy positions, so yes, technically, you could use it.. however, I don't see any functions to load an existing pdf. There is a mention of importing an existing pdf through FPDI

Posted: Sun Jan 09, 2005 1:19 pm
by AGISB
I would actually ask Adobe for a solution. As you boss will have to pay for every software he might drop the idea if it is overly expensive ;)

An approach I successfully used many times ;)