mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 05:24:35 -04:00
Fixes for preview PDF using phantom js
This commit is contained in:
parent
e99cb4436e
commit
b593cb0ff3
@ -121,6 +121,12 @@ class PreviewController extends BaseController
|
|||||||
->design($design)
|
->design($design)
|
||||||
->build();
|
->build();
|
||||||
|
|
||||||
|
//if phantom js...... inject here..
|
||||||
|
if (config('ninja.phantomjs_pdf_generation')) {
|
||||||
|
return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
//else
|
||||||
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
|
||||||
|
|
||||||
return response()->download($file_path)->deleteFileAfterSend(true);
|
return response()->download($file_path)->deleteFileAfterSend(true);
|
||||||
|
@ -84,6 +84,15 @@ class Phantom
|
|||||||
return $file_path;
|
return $file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function convertHtmlToPdf($html)
|
||||||
|
{
|
||||||
|
// https://phantomjscloud.com/api/browser/v2/a-demo-key-with-low-quota-per-ip-address/?request=%7Bcontent:%22%3Chtml%3E%3Ch1%3Eboo%3C/h2%3E%3C/html%3E%22,renderType:%22pdf%22%7D
|
||||||
|
|
||||||
|
$key = config('ninja.phantomjs_key');
|
||||||
|
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Bcontent:%22{$html}%22,renderType:%22pdf%22%7D";
|
||||||
|
return CurlUtils::get($phantom_url);
|
||||||
|
}
|
||||||
|
|
||||||
public function displayInvitation(string $entity, string $invitation_key)
|
public function displayInvitation(string $entity, string $invitation_key)
|
||||||
{
|
{
|
||||||
$key = $entity.'_id';
|
$key = $entity.'_id';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user