mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix for #713
This commit is contained in:
parent
f5bb3d3f1b
commit
331b117189
@ -733,40 +733,18 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
|
||||
$invitation = $this->invitations[0];
|
||||
$link = $invitation->getLink();
|
||||
$key = env('PHANTOMJS_CLOUD_KEY');
|
||||
$curl = curl_init();
|
||||
|
||||
if (Utils::isNinjaDev()) {
|
||||
$link = env('TEST_LINK');
|
||||
}
|
||||
|
||||
$jsonEncodedData = json_encode([
|
||||
'url' => "{$link}?phantomjs=true",
|
||||
'renderType' => 'html',
|
||||
'outputAsJson' => false,
|
||||
'renderSettings' => [
|
||||
'passThroughHeaders' => true,
|
||||
],
|
||||
// 'delayTime' => 1000,
|
||||
]);
|
||||
|
||||
$opts = [
|
||||
CURLOPT_URL => PHANTOMJS_CLOUD . env('PHANTOMJS_CLOUD_KEY') . '/',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => $jsonEncodedData,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: '.strlen($jsonEncodedData)
|
||||
],
|
||||
];
|
||||
|
||||
curl_setopt_array($curl, $opts);
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$pdfString = strip_tags($response);
|
||||
|
||||
$url = "http://api.phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$link}?phantomjs=true%22,renderType:%22html%22%7D";
|
||||
|
||||
$pdfString = file_get_contents($url);
|
||||
$pdfString = strip_tags($pdfString);
|
||||
|
||||
if ( ! $pdfString || strlen($pdfString) < 200) {
|
||||
Utils::logError("PhantomJSCloud - failed to create pdf: {$pdfString}");
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user