diff --git a/php-classes/RequestHandler.class.php b/php-classes/RequestHandler.class.php index 413ab04ac..44b496bd0 100644 --- a/php-classes/RequestHandler.class.php +++ b/php-classes/RequestHandler.class.php @@ -166,22 +166,25 @@ public static function respondPrint($responseID, $responseData = array(), $forma $tmpPath = tempnam('/tmp', 'e_pdf_'); file_put_contents($tmpPath.'.html', $html); - - header('Content-Type: application/pdf'); - header('Content-Disposition: attachment; filename="'.str_replace('"', '', $responseID).'.pdf"'); - - exec(implode(' ', [ + + $command = implode(' ', [ static::$wkhtmltopdfPath, static::$wkhtmltopdfArguments, escapeshellarg($tmpPath.'.html'), escapeshellarg($tmpPath.'.pdf') - ])); - + ]); + + $output = exec($command); + if (!file_exists("$tmpPath.pdf")) { header('HTTP/1.0 501 Not Implemented'); - die('Unable to generate PDF, check that this system has wkhtmltopdf installed'); + header('Content-Type: text/plain'); + die("Unable to generate PDF, see command/output below and check that this system has wkhtmltopdf installed.\n\ncommand: {$command}\n\noutput: {$output}"); } - + + header('Content-Type: application/pdf'); + header('Content-Disposition: attachment; filename="'.str_replace('"', '', $responseID).'.pdf"'); + readfile($tmpPath.'.pdf'); exit(); } elseif ($format == 'html') { diff --git a/php-classes/SQL.class.php b/php-classes/SQL.class.php index e81acf316..984581b80 100644 --- a/php-classes/SQL.class.php +++ b/php-classes/SQL.class.php @@ -140,8 +140,9 @@ public static function getSQLType($field) return sprintf(!$field['length'] || $field['type'] == 'varchar' ? 'varchar(%u)' : 'char(%u)', $field['length'] ? $field['length'] : 255); case 'clob': case 'serialized': - case 'json': return 'text'; + case 'json': + return 'json'; case 'blob': return 'blob';