Skip to content
Snippets Groups Projects
Commit 52572aa7 authored by Kevin Kaland's avatar Kevin Kaland
Browse files

Issue #1876832: Fix pdftk path check.

parent 94f2e53a
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ function fillpdf_settings($form, &$form_state) { ...@@ -36,7 +36,7 @@ function fillpdf_settings($form, &$form_state) {
} }
// Check for pdftk. // Check for pdftk.
$status = fillpdf_pdftk_check(variable_get('fillpdf_pdftk_path', 'pdftk')); $status = fillpdf_pdftk_check(fillpdf_pdftk_path());
if ($status === FALSE) { if ($status === FALSE) {
$options['pdftk'] .= '<div class="messages warning">' . t('pdftk is not properly installed.') . '</div>'; $options['pdftk'] .= '<div class="messages warning">' . t('pdftk is not properly installed.') . '</div>';
} }
......
...@@ -710,7 +710,7 @@ function fillpdf_execute_merge($method, $fields, $fillpdf, $mode = 'url', $flatt ...@@ -710,7 +710,7 @@ function fillpdf_execute_merge($method, $fields, $fillpdf, $mode = 'url', $flatt
$xfdffile = file_save_data($xfdf, $xfdfname, FILE_EXISTS_RENAME); $xfdffile = file_save_data($xfdf, $xfdfname, FILE_EXISTS_RENAME);
// Now feed this to pdftk and save the result to a variable // 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(); ob_start();
passthru($path_to_pdftk . ' ' . escapeshellarg(drupal_realpath($filename)) . ' fill_form ' . escapeshellarg(drupal_realpath($xfdffile->uri)) . ' output - ' . ($flatten ? 'flatten ' : '') . 'drop_xfa'); passthru($path_to_pdftk . ' ' . escapeshellarg(drupal_realpath($filename)) . ' fill_form ' . escapeshellarg(drupal_realpath($xfdffile->uri)) . ' output - ' . ($flatten ? 'flatten ' : '') . 'drop_xfa');
$data = ob_get_clean(); $data = ob_get_clean();
...@@ -807,7 +807,7 @@ function fillpdf_execute_parse($method, $fillpdf, $mode = 'url') { ...@@ -807,7 +807,7 @@ function fillpdf_execute_parse($method, $fillpdf, $mode = 'url') {
break; break;
} }
$path_to_pdftk = variable_get('fillpdf_pdftk_path', 'pdftk'); $path_to_pdftk = fillpdf_pdftk_path();
$status = fillpdf_pdftk_check($path_to_pdftk); $status = fillpdf_pdftk_check($path_to_pdftk);
if ($status === FALSE) { if ($status === FALSE) {
drupal_set_message(t('pdftk not properly installed.'), 'error'); drupal_set_message(t('pdftk not properly installed.'), 'error');
...@@ -1014,3 +1014,13 @@ function fillpdf_pdftk_check($pdftk_path = 'pdftk') { ...@@ -1014,3 +1014,13 @@ function fillpdf_pdftk_check($pdftk_path = 'pdftk') {
return TRUE; 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';
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment