summaryrefslogtreecommitdiff
path: root/latex.inc
diff options
context:
space:
mode:
authorprashantsinalkar2016-08-25 17:41:08 +0530
committerprashantsinalkar2016-08-25 17:41:08 +0530
commit2b1d2388486dd66aabdc8138befac022e46df7ef (patch)
treef781d2d0b3a2e92982befab9f9a3ef89a47c6879 /latex.inc
parent97293a319090cc0fdb03aea06bb9fab0ae0f96f3 (diff)
downloadscilab_textbook_companion-2b1d2388486dd66aabdc8138befac022e46df7ef.tar.gz
scilab_textbook_companion-2b1d2388486dd66aabdc8138befac022e46df7ef.tar.bz2
scilab_textbook_companion-2b1d2388486dd66aabdc8138befac022e46df7ef.zip
added error message when pdf is generated as 0 byte
Diffstat (limited to 'latex.inc')
-rwxr-xr-xlatex.inc39
1 files changed, 26 insertions, 13 deletions
diff --git a/latex.inc b/latex.inc
index 553e2d7..942989d 100755
--- a/latex.inc
+++ b/latex.inc
@@ -45,7 +45,7 @@ function _latex_generate_files($preference_id, $full_book = FALSE)
//var_dump(file_exists($dir_path . "book_" . $preference_data->id . ".pdf"));die;
if (file_exists($dir_path . "book_" . $preference_data->id . ".pdf"))
{
- /* download zip file */
+ /* download PDF file */
ob_clean();
header("Pragma: public");
header("Expires: 0");
@@ -167,17 +167,31 @@ function _latex_generate_files($preference_id, $full_book = FALSE)
//var_dump($dir_path . "book_" . $preference_data->id . ".pdf");die;
if (_latex_run_script($book_filename, $contributor_filename, $latex_filename, $latex_dep_filename, $pdf_filename))
{
- /* download zip file */
- header('Content-Type: application/pdf');
- header('Content-disposition: attachment; filename="' . $preference_data->book . '_' . $preference_data->author . '.pdf"');
- header('Content-Length: ' . filesize($dir_path . $pdf_filename));
- header("Content-Transfer-Encoding: binary");
- header('Expires: 0');
- header('Pragma: no-cache');
- @readfile($dir_path . $pdf_filename);
- ob_end_flush();
- ob_clean();
- flush();
+ /* download PDF file */
+ if (filesize($dir_path . $pdf_filename) == TRUE)
+ {
+ ob_clean();
+ header("Pragma: public");
+ header("Expires: 0");
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+ header("Cache-Control: public");
+ header("Content-Description: File Transfer");
+ header('Content-Type: application/pdf');
+ header('Content-disposition: attachment; filename="' . $preference_data->book . '_' . $preference_data->author . '.pdf"');
+ header('Content-Length: ' . filesize($dir_path . $pdf_filename));
+ header("Content-Transfer-Encoding: binary");
+ header('Expires: 0');
+ header('Pragma: no-cache');
+ @readfile($dir_path . $pdf_filename);
+ ob_end_flush();
+ ob_clean();
+ flush();
+ } //filesize($dir_path . $pdf_filename) == TRUE
+ else
+ {
+ drupal_set_message("Error occurred when generating the PDF version of the Book.", 'error');
+ drupal_goto('textbook_run/' . $preference_data->id);
+ }
} //_latex_run_script($book_filename, $contributor_filename, $latex_filename, $latex_dep_filename, $pdf_filename)
else
{
@@ -223,4 +237,3 @@ function textbook_companion_delete_book()
drupal_goto('code_approval/bulk');
return;
}
-