Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Text boxers
________________
Name [________________] <---- text box.

In the same form as the paper they want printed.
 
All right. I tested the example I posted a while back just now to make sure it really is working in its current form, and it does work. I'll outline the steps I took that worked. I used MAMP as the test environment. You can test it on a real live server if you prefer.

Does everything below make sense to you? If not, where are you having trouble?

=-=-=

Okay, here we go:

First, I created a simple file in TextEdit with two silly questions ("what is your name?" and "do you like onions?"). I then save this as a PDF file using the regular Mac print dialog.

=-=-=

Next, I opened the PDF with Acrobat Pro, tuened on the advanced editing toolbar, and added two form fields. Beside the first question, I added a text field and called it "yourname". Beside the second question, i added a check box and called it "likeonions". Under the options tab of the check box properties, I changed the export value to on so that it will match the Web form values. I saved this file as mydoc.pdf

=-=-=

I downloaded the ZIP archive from http://koivi.com/fill-pdf-form-fields/ and dragged it into the htdocs folder of my MAMP directory. For convenience, I renamed the folder to fillpdf, but that's not so important. inside the fillpdf folder, I created a new folder called results, because the one in the ZIP archive was incorrectly extracted. I also dragged a copy of the mydoc.pdf created in the past step into the fillpdf folder.

=-=-=

Inside the fillpdf folder, I edited example_form.html so that it looks as follows:
HTML:
<form method="post" action="process-xfdf.php">
 <fieldset>
  <table>
   <tr><td>Enter Your Name</td><td><input type="text" name="yourname" /></td></tr>
   <tr><td>Do you like onions?</td><td><input type="checkbox" name="likeonions" /></td></tr>
  </table>
  <input type="submit" name="submit" value="Generate FDF Data" />
 </fieldset>
</form>

Notice that I added the name "submit" to the submit input at the bottom, this will be needed to make some of the sample PHP happy.

=-=-=

The next step was to edit process-xfdf.php. I changed $mailto and $from to be real addresses, and changed $pdf_file to be the URL of the PDf form (in my case, 'http://localhost:8888/fillpdf/mydoc.pdf' ). Just below that, I set $redirect to any old page (this prevents the completed PDF from being displayed in the browser).

Also, the $text_fields array had to be changed to contain ('yourname', 'likeonions') instead of the sample names.

=-=-=

That should be all. I go to localhost:8888/fillpdf/example_form.html in my browser, fill in the form, and press submit. After a few moments, a message appears in my mail with the completed .xfdf file attached. If I open this attachment in my mail, it opens the Web browser and merges the data into the online PDF (the PDF could have been offline too, but I wanted to stick with the example). From there, I can save or print it.

=-=-=-=

Just adding some random bits:

If you would rather have the PDF be a local file so that a browser doesn't need to open, copy it to wherever you need and put its full path into the $pdf_file variable. You would want to use the bare (Unix or DOS style) path, not with the file:// prefix, to avoid browser usage.

If you want to do more than print the merged form, the users will need Acrobat. Reader is limited to display and print. You may or may not care, if may be good enough to save the .xfdf files.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.