1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fix PDF on older IE

This commit is contained in:
Hillel Coren 2017-05-24 11:00:35 +03:00
parent d7373a133b
commit 0b90e6e512
3 changed files with 30 additions and 7 deletions

View File

@ -200,7 +200,8 @@ class ClientPortalController extends BaseController
}
$invoice = $invitation->invoice;
$pdfString = $invoice->getPDFString();
$decode = ! request()->base64;
$pdfString = $invoice->getPDFString($decode);
header('Content-Type: application/pdf');
header('Content-Length: ' . strlen($pdfString));

View File

@ -1231,7 +1231,7 @@ class Invoice extends EntityModel implements BalanceAffecting
/**
* @return bool|string
*/
public function getPDFString()
public function getPDFString($decode = true)
{
if (! env('PHANTOMJS_CLOUD_KEY') && ! env('PHANTOMJS_BIN_PATH')) {
return false;
@ -1271,11 +1271,15 @@ class Invoice extends EntityModel implements BalanceAffecting
return false;
}
if ($pdf = Utils::decodePDF($pdfString)) {
return $pdf;
if ($decode) {
if ($pdf = Utils::decodePDF($pdfString)) {
return $pdf;
} else {
Utils::logError("PhantomJS - Unable to decode: {$pdfString}");
return false;
}
} else {
Utils::logError("PhantomJS - Unable to decode: {$pdfString}");
return false;
return $pdfString;
}
}

View File

@ -114,7 +114,25 @@
var needsRefresh = false;
function refreshPDF(force) {
return getPDFString(refreshPDFCB, force);
try {
return getPDFString(refreshPDFCB, force);
} catch (exception) {
$.get('http://ninja.dev/download/kamdswrgu9adbmojwlvmsfyzc6a3zd42?base64=true', function(result) {
refreshPDFCB(result);
})
return false;
}
/*
@if (true || isset($usePhantomJS) && $usePhantomJS)
$.get('http://ninja.dev/download/kamdswrgu9adbmojwlvmsfyzc6a3zd42?base64=true', function(result) {
refreshPDFCB(result);
})
return false;
@else
return getPDFString(refreshPDFCB, force);
@endif
*/
}
function refreshPDFCB(string) {