diff --git a/fillpdf.admin.inc b/fillpdf.admin.inc index 16346455d18efdbddf4ed0a687812e9e6e5b1c48..892c0283277cdb662452a4df9508911c9bd7ccd6 100644 --- a/fillpdf.admin.inc +++ b/fillpdf.admin.inc @@ -36,7 +36,7 @@ function fillpdf_settings($form, &$form_state) { } // Check for pdftk. - $status = fillpdf_pdftk_check(variable_get('fillpdf_pdftk_path', 'pdftk')); + $status = fillpdf_pdftk_check(fillpdf_pdftk_path()); if ($status === FALSE) { $options['pdftk'] .= '<div class="messages warning">' . t('pdftk is not properly installed.') . '</div>'; } diff --git a/fillpdf.module b/fillpdf.module index c20b8aaa2c21030ae2813b734856bae7465b643e..a0698b7e5aaed49f223723b7d23f3d004f1e99de 100644 --- a/fillpdf.module +++ b/fillpdf.module @@ -710,7 +710,7 @@ function fillpdf_execute_merge($method, $fields, $fillpdf, $mode = 'url', $flatt $xfdffile = file_save_data($xfdf, $xfdfname, FILE_EXISTS_RENAME); // Now feed this to pdftk and save the result to a variable - $path_to_pdftk = variable_get('fillpdf_pdftk_path', 'pdftk'); + $path_to_pdftk = fillpdf_pdftk_path(); ob_start(); passthru($path_to_pdftk . ' ' . escapeshellarg(drupal_realpath($filename)) . ' fill_form ' . escapeshellarg(drupal_realpath($xfdffile->uri)) . ' output - ' . ($flatten ? 'flatten ' : '') . 'drop_xfa'); $data = ob_get_clean(); @@ -807,7 +807,7 @@ function fillpdf_execute_parse($method, $fillpdf, $mode = 'url') { break; } - $path_to_pdftk = variable_get('fillpdf_pdftk_path', 'pdftk'); + $path_to_pdftk = fillpdf_pdftk_path(); $status = fillpdf_pdftk_check($path_to_pdftk); if ($status === FALSE) { drupal_set_message(t('pdftk not properly installed.'), 'error'); @@ -1014,3 +1014,13 @@ function fillpdf_pdftk_check($pdftk_path = 'pdftk') { return TRUE; } +// This is a convenience wrapper around variable_get(). It lets us **also** +// return "pdftk" if the variable is empty, not just unset. +function fillpdf_pdftk_path() { + $path_to_pdftk = variable_get('fillpdf_pdftk_path', 'pdftk'); + if ($path_to_pdftk) { + return $path_to_pdftk; + } + return 'pdftk'; +} +