Unfortunately I am having serious issues with my current PHP=>FDF=>PDF script. It works perfect each time for me, my co-workers, my boss, and my friends I have shown it to. Other people, however, can't seem to get it to work at all. Some just get the FDF file in plain text (I'm assuming they didn't install and open Adobe Acrobat Reader properly.), and others claim they just get a blank page. I'm thinking there has to be a way for me to use Adobe Acrobat to generate a PDF document, and use PHP to open that file, manipulate the form elements in it, and save it as a uniqe file. This way the person only needs to be able to download a PDF file and open it. I just don't want to have to rely on internet explorer realising it is not a good idea to cache headers. Anyone know of a good way to do this? I'm not talking about generating PHP from scratch. IMO that would be near impossible due to the complexity of this form. (Over 100 form elements on this form, btw.) I just want to make a copy of a PDF document and manipulate the form values. Make check boxes checked, radio buttons selected, and fill in text fields. Help?
off topic i bit i know but i would be interested to know how your script works or if you followwed a guide on the web a link would be appreciated. cheers!
PHP: function fdf($url, $data){ $fdfdata = "%FDF-1.2\n%âãÏÓ\n"; $fdfdata .= "1 0 obj \n<< /FDF "; $fdfdata .= "<< /Fields [\n"; //loop that adds the field names and values if(is_array($data)) { foreach($data as $key=>$val) { $fdfdata.="<< /V ($val)/T ($key) >> "; } } $fdfdata .= "]\n"; $fdfdata .= "/F ($url) >>"; $fdfdata .= ">>\nendobj\ntrailer\n<<\n/Root 1 0 R\n>>\n"; $fdfdata .= "%%EOF"; //uncomment if you actually want to write a FDF file //touch ($form.".fdf"); //$FD = fopen ($form.".fdf", "w"); //fwrite($FD,$fdfdata); //fclose ($FD); /*** Now we display the FDF data which causes Acrobat to start ***/ header ("Content-Type: application/vnd.fdf"); print $fdfdata; die(); } So what this does is just creates an FDF file, which is one of Adobe's newish toys to fill in form fields. Go grab Adobe Acrobat, make a PDF with 2 text boxes, one named "bob" and one named "larry". Then run: PHP: include("That script up there"); $foo["bob"]="tomato"; $foo["larry"]="cucumber"; fdf($foo, "http://yoursite.com/pdf_with_form.pdf"); What that does is sets the array foo with keys that line up with the PDF form elements and just puts the values of that array into the FDF file. The FDF file then calls the PDF form. Pretty cool, IMO. Not sure who wrote this, I've found different variations, and this one may have come from zend's own site. I'll post the URL when I find it.
Silly question... Have you ensured that all users for whom this app hasn;t worked have REinstalled adobe. We found in system testing (though we dont use forms) that some people couldn't read the generated PDFS - it was because of dud links in their registry. A complete reinstallation of the new read seemd to sort it. This was despite them being able to run the adobe reader correctly on standalone things.
Hepath, glad you mentioned that. We may start asking people to reinstall. Fortunately with a new version out, we can tell them just to upgrade to version 7. This has worked every time so far, so hopefully reinstalling will solve all of my problems in the future. The tool is working rather well, and it's cool because I work in the office that receives the form that was printed, so I get to see the fruits of my labor all the time So far since the tool's launch on January 24th, we've had almost 8,000 page hits with no issues. (as of 2/3, making it roughly 725 hits per day, actually over 875 if you consider this isn't used over the weekends.) This app is runing on a linux box I set up a few months ago. It's an old Pentium 3 with 256 Mb of RAM, but we did buy a decent battery backup and server certificate to make it look like a real server