Man, talk about a frustrating problem! I kept getting this errors while calling pdftk (from the mac installer, which the version as of this writing is 1.12):

Unhandled Java Exception:
java.io.CharConversionException
   <<No stacktrace available>>

Anyway, after much hair pulling, the answer was found! Before calling shell_exec (or whatever function you use to call pdftk) you need to unset the DYLD_LIBRARY_PATH environment variable.

# unset this so pdftk will work!
putenv(‘DYLD_LIBRARY_PATH’);
 
# put the output in a variable
$pdf_data = shell_exec(‘/usr/local/bin/pdftk ‘. $file_name .‘ fill_form ‘. 
$fdf_fn. ‘ output – flatten’);