This is clunky but it gets the job done:
Use createXFDF.php and then use PDFTK twice.
Make sure your template pdf has extended features in Adobe Reader.
Create an XFDF file with the data you will use to populate the PDF - remember that field names in pdf must match those in the xfdf. The data is an array of field name, field value.
Use PDFTK with your template pdf and the XFDF to create a new intermediate PDF. Do NOT use FLATTEN - that will remove editability.
Now use PDFTK cat with your new intermediate PDF to create your final PDF - it somehow gets rid of the Adobe digital signature (Keep a pdf form editable after filling it with pdftk - see Marco's answer).
Sample code:
$data = array();
$field_name = "account_directory";
$field_value = "john_smith";
$data[$field_name] = $field_value;
/* Make $data as big as you need with as many field names/values
as you need to populate your pdf */
$pdf_template_url = 'http://yoursite.com/yourpath/yourtemplate.pdf';
include 'createXFDF.php';
$xfdf = createXFDF( $pdf_template_url, $data );
/* Set up the temporary file name for xfdf */
$filename = "temp_file.xfdf";
/* Create and write the XFDF for this application */
$directory = $_SERVER['DOCUMENT_ROOT']."/path_to_temp_files/";
$xfdf_file_path = $directory.$filename ; /* needed for PDFTK */
// Open the temp xfdf file and erase the contents if any
$fp = fopen($directory.$filename, "w");
// Write the data to the file
fwrite($fp, $xfdf);
// Close the xfdf file
fclose($fp);
/* Write the pdf for this application - Temporary, then Final */
$pdf_template_path = '/yourpath/yourtemplate.pdf';
$pdftk = '/path/to/pdftk'; /* location of PDFTK */
$temp_pdf_file_path = substr( $xfdf_file_path, 0, -4 ) . 'pdf';
$command = "$pdftk $pdf_template_path fill_form $xfdf_file_path output $temp_pdf_file_path";
/* Note that the created file is NOT flattened so that recipient
can edit form - but this is not enough to allow edit with
Adobe Reader: will also need to remove the signature with PDFTK cat */
exec( $command, $output, $ret );
/* Workaround to get editable final pdf */
$pdf_path_final = $directory. "your_final_filename.pdf" ;
$command2 = "$pdftk $temp_pdf_file_path cat output $pdf_path_final";
exec( $command2, $output2, $ret2 );
/* Your pdf is now saved
/* Remember to UNLINK any files you don't want to save - the .xfdf and the temporary pdf */