Expand my Community achievements bar.

Populate Livecycle PDF from mySQL database using PHP

Avatar

Former Community Member
I'm trying to set up a database of loan agreements, where users will submit a form through Acrobat and their information will be stored in a mySQL database. Later, they can go back and download the PDF, which will be repopulated with their data in the mySQL db.



I made the form in Livecycle Designer and submit the information through HTTP POST. I can easily get the information from the form into the database...my only problem is getting that information back out into the PDF.



What would allow me to write back to the PDF, preferably using PHP? What kind of syntax would that require?



Thanks!
28 Replies

Avatar

Former Community Member
I managed to get up to the pdftk step - however I get an error can't open pdf file. I am searching for a work through of this

Avatar

Former Community Member
I have everything setup and I may be missing something, but when I go to viewpdf and the id#, I get a huge error pop-up saying that Acrobat Reader could not open....

Avatar

Former Community Member
I am curious to if you found a solution. I have been tinkering for days and cannot resolve the issue. I have tried three different servers and all the same results: Two linux and one Windows 2003.

Avatar

Former Community Member
It seems possible that LiveCycle Designer can be used to create a form for entering and retrieving data from a Google spreadsheet via a WSDL file.



Could someone point me to a tutorial, instructions, or a blog that describes how to do this?



Thanks, Keith Silva

Avatar

Former Community Member
Ok, for all of those that have been having problems with the corrupted PDF at the end, I finally figured it out.<br /><br />Obviously, if you're running on a Linux server, you can't use the pdftk.exe because it's a windows executable. <br /><br />Go to this page, http://www.pdfhacks.com/pdftk/, and look for your flavor of Linux. My Virtual Private Server was running a version of RedHat, so that was the version I chose. I dowloaded the .gz from:<br /><br /> Download and unpack: pdftk-1.41.tar.gz (~0.9MB), or: pdftk-1.41.tar.bz2 (~0.7MB)<br /><br />Once it was downloaded, I unpacked it to a folder and uploaded the all three folders (pdftk, java, and debian) via ftp to my server into a subfolder of my http://<yoursitehere>/PDF/<br /><br />I ssh'd in and entered into that subdirectory (don't put the ") "make -f Makefile.RedHat". It spent some time compiling and then generated my very own pdftk for Linux!! I moved that file to the directory with my PHP code and made one small modification (see below).<br /><br />In the viewpdf.php file you may need to change the line:<br />passthru( 'pdftk LoanAgreement.pdf fill_form '. $fdf_fn.<br /> ' output - flatten' );<br /><br />to<br /><br />passthru( './pdftk LoanAgreement.pdf fill_form '. $fdf_fn.<br /> ' output - flatten' );<br /><br />I had no problems from here! I hope this helps people!

Avatar

Former Community Member
Hi all,



I'm trying to get a system set up that is similar to what many have posted here, but I'm running into a problem. Here's the general workflow I want to occur:

] 1) Create a fillable PDF form in Adobe LiveCycle Designer, giving some fields specific names which we want to automatically fill in for the user later. Save the PDF to a certain place on my server.

] 2) A user logs into a website on my server and:

] 2a) A script running on the webserver looks at the user's credentials and grabs relevant information from a database that we'll be sticking into the PDF

] 2b) We generate an FDF on the fly containing the user's information (using
http://www.pdfhacks.com/forge_fdf/)

] 2c) We run PDFTK with the fill_form parameter on the PDF, specifying the FDF we just made

] 2d) We serve the pre-poulated (*BUT STILL FILLABLE*) PDF form to the user

] 3) The user fills out any remaining fields (and potentially modifies the pre-populated data we gave them) and prints out the PDF or saves it locally (I'm not worried about electronic submission right now).



Thanks to Andrew Heiss' excellent tutorial (
http://www.andrewheiss.com/Tutorials?page=LiveCycle_PDFs_and_MySQL), and the PDFTK site (
http://www.pdfhacks.com/pdftk/), I got *most* of this working already. However, using the "flatten" parameter with pdftk produces a PDF which is *not* fillable (the form fields are populated fine, but they're greyed out and can't be edited).



Several sites have mentioned that removing the "flatten" parameter will leave the PDF fillable, but when I run PDFTK without "flatten", it spits the original PDF back at me, without populating any of the fields (but PDFTK *doesn't* generate any errors).



I've tried this on several different clients with different versions of PDF reader, but the result is always the same: the "flattened" PDF is always unfillable, and the "unflattened" PDF is always not pre-populated.



Has anyone else experienced this kind of problem? Am I doing something WAY wrong?



I'm frustratingly close to getting this working... Any ideas, workarounds, or other avenues I should be exploring would be greatly appreciated.



Thanks!

- Ryan

Avatar

Former Community Member
Hi Ryan:



did you found a solution to your problem?



I've tried to fill that form with pdftk and iText library(java) but i can't get the form fillable and pre-populated.



Thanks!

Avatar

Former Community Member
Hi Sebas,



Glad to know someone else is having the same issue and I'm not just crazy.



As far as I can tell, a PDF form created in Adobe LiveCycle Designer can not be both pre-populated with PDFTK *AND* remain editable, although it can be populated and flattened if you just need to directly print it.



A PDF form created using Adobe Acrobat Pro 9 (using Forms > Add or Edit fields, rather than Forms > Start Form Wizard -- which launches LiveCycle) works just fine and can be pre-populated with PDFTK and still remain editable.



Since the full enterprise package dealy of LiveCycle is way outside of my organization's budget, we decided to just use Acrobat Pro to make the forms. It's a shame, because LiveCycle Designer is a really slick program. Hopefully Adobe doesn't completely remove form editing capabilities from Acrobat Pro in the next version (and if someone from Adobe reads this post... PLEASE don't remove this functionality from Acrobat Pro! Pretty please!)



One work-around that I discovered is that if you view a PDF form in browser, you can specify a remote FDF in the URL for the client to try to get pre-population data from when it displays the PDF to the user (I believe the syntax is http://somewebsite.com/theform.pdf#FDF=http://somewebsite.com/thedata.fdf ). That solution has a couple of drawbacks (namely that you can't save an off-line version of it) and wasn't quite what we needed, but it might be useful to some people.



That's what I was able to find after scouring the Tubes for answers and playing around with stuff. Keep in mind I'm not a PDF expert and it's very possible that I'm overlooking something, so if anyone else has suggestions, please share!



- Ryan