mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improve invoice getPDFString
This commit is contained in:
parent
8f409bf889
commit
7889350fd8
@ -1203,7 +1203,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
}
|
}
|
||||||
|
|
||||||
$invitation = $this->invitations[0];
|
$invitation = $this->invitations[0];
|
||||||
$link = $invitation->getLink('view', true);
|
$link = $invitation->getLink('view', true, true);
|
||||||
$pdfString = false;
|
$pdfString = false;
|
||||||
$phantomjsSecret = env('PHANTOMJS_SECRET');
|
$phantomjsSecret = env('PHANTOMJS_SECRET');
|
||||||
$phantomjsLink = $link . "?phantomjs=true&phantomjs_secret={$phantomjsSecret}";
|
$phantomjsLink = $link . "?phantomjs=true&phantomjs_secret={$phantomjsSecret}";
|
||||||
@ -1213,8 +1213,10 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
// we see occasional 408 errors
|
// we see occasional 408 errors
|
||||||
for ($i=1; $i<=5; $i++) {
|
for ($i=1; $i<=5; $i++) {
|
||||||
$pdfString = CurlUtils::phantom('GET', $phantomjsLink);
|
$pdfString = CurlUtils::phantom('GET', $phantomjsLink);
|
||||||
if ($pdfString) {
|
if (strpos($pdfString, 'data') === 0) {
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
$pdfString = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1239,7 +1241,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
if ($pdf = Utils::decodePDF($pdfString)) {
|
if ($pdf = Utils::decodePDF($pdfString)) {
|
||||||
return $pdf;
|
return $pdf;
|
||||||
} else {
|
} else {
|
||||||
Utils::logError("PhantomJS - Unable to decode {$phantomjsLink}: {$pdfString}");
|
Utils::logError("PhantomJS - Unable to decode {$phantomjsLink}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user