Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fillpdf
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
fillpdf
Commits
eabc649f
Commit
eabc649f
authored
5 years ago
by
lkmorlan
Committed by
Liam Morland
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fillpdf.module
+18
-0
18 additions, 0 deletions
fillpdf.module
with
18 additions
and
0 deletions
fillpdf.module
+
18
−
0
View file @
eabc649f
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment