Skip to content

Commit

Permalink
Merge pull request #176 from JarvusInnovations/develop
Browse files Browse the repository at this point in the history
Release: emergence-skeleton v1.3.22
  • Loading branch information
themightychris authored Dec 9, 2018
2 parents 54060ad + d21402f commit 0c38c47
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
21 changes: 12 additions & 9 deletions php-classes/RequestHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
3 changes: 2 additions & 1 deletion php-classes/SQL.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 0c38c47

Please sign in to comment.