Skip to content
Snippets Groups Projects
Commit eabc649f authored by lkmorlan's avatar lkmorlan Committed by Liam Morland
Browse files

Issue #3036845 by Liam Morland: Display error page when pdftk fails

parent 47bb1726
No related branches found
No related tags found
No related merge requests found
...@@ -330,6 +330,12 @@ function fillpdf_parse_uri($uri = NULL) { ...@@ -330,6 +330,12 @@ function fillpdf_parse_uri($uri = NULL) {
$context = fillpdf_link_to_stub_context($uri); $context = fillpdf_link_to_stub_context($uri);
fillpdf_merge_pdf($context['fid'], $context['nids'], $context['webforms'], $context['sample'], $context['force_download'], FALSE, $context['flatten'], TRUE, $context['uc_order_ids'], $context['uc_order_product_ids'], $context['entity_ids']); fillpdf_merge_pdf($context['fid'], $context['nids'], $context['webforms'], $context['sample'], $context['force_download'], FALSE, $context['flatten'], TRUE, $context['uc_order_ids'], $context['uc_order_product_ids'], $context['entity_ids']);
// Normally, fillpdf_merge_pdf() calls fillpdf_merge_perform_pdf_action()
// which send the PDF to the browser and calls drupal_exit(). If there is an
// error, it will not exit. Returning empty string ensures that a page is
// rendered on which to display error messages.
return '';
} }
/** /**
...@@ -763,6 +769,10 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_array = NULL, $sample = ...@@ -763,6 +769,10 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_array = NULL, $sample =
} }
$data = fillpdf_execute_merge($method, $fields, $fillpdf_info, 'url', $flatten, $image_data); $data = fillpdf_execute_merge($method, $fields, $fillpdf_info, 'url', $flatten, $image_data);
if (!$data) {
return;
}
if (!empty($webform['webform'])) { if (!empty($webform['webform'])) {
$node = $webform['webform']; $node = $webform['webform'];
} }
...@@ -1092,6 +1102,11 @@ function fillpdf_merge_perform_pdf_action($fillpdf_object, $action = 'download', ...@@ -1092,6 +1102,11 @@ function fillpdf_merge_perform_pdf_action($fillpdf_object, $action = 'download',
return; return;
} }
// If the PDF is empty, return.
if (!$pdf_data) {
return;
}
// Generate the filename of downloaded PDF from title of the PDF set in // Generate the filename of downloaded PDF from title of the PDF set in
// admin/structure/fillpdf/%fid. // admin/structure/fillpdf/%fid.
$output_name = _fillpdf_process_filename($pdf_info->title, $token_objects); $output_name = _fillpdf_process_filename($pdf_info->title, $token_objects);
...@@ -1554,6 +1569,9 @@ function fillpdf_execute_merge($method, array $fields, $fillpdf, $mode = 'url', ...@@ -1554,6 +1569,9 @@ function fillpdf_execute_merge($method, array $fields, $fillpdf, $mode = 'url',
if ($data === FALSE) { if ($data === FALSE) {
$error = t('pdftk not properly installed. No PDF generated.'); $error = t('pdftk not properly installed. No PDF generated.');
} }
elseif (!$data) {
$error = t('Error with pdftk. No PDF generated.');
}
if ($error) { if ($error) {
drupal_set_message($error, 'error'); drupal_set_message($error, 'error');
watchdog('fillpdf', $error, array(), WATCHDOG_ERROR); watchdog('fillpdf', $error, array(), WATCHDOG_ERROR);
......
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