mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01: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)
|
||||
->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());
|
||||
|
||||
return response()->download($file_path)->deleteFileAfterSend(true);
|
||||
|
@ -84,6 +84,15 @@ class Phantom
|
||||
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)
|
||||
{
|
||||
$key = $entity.'_id';
|
||||
|
Loading…
Reference in New Issue
Block a user