Mysql -> PHP -> PDF Mailmerge Challange!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
abshaw
Forum Commoner
Posts: 33
Joined: Thu Feb 19, 2004 7:14 pm

Mysql -> PHP -> PDF Mailmerge Challange!!

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
abshaw
Forum Commoner
Posts: 33
Joined: Thu Feb 19, 2004 7:14 pm

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
abshaw
Forum Commoner
Posts: 33
Joined: Thu Feb 19, 2004 7:14 pm

Post 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:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe having php write the postscript needed to generate it, then pass that to a pdf creation tool?
abshaw
Forum Commoner
Posts: 33
Joined: Thu Feb 19, 2004 7:14 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
abshaw
Forum Commoner
Posts: 33
Joined: Thu Feb 19, 2004 7:14 pm

Post 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 ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post 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 ;)
Post Reply