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

Refactor PDF generation into common .env var

This commit is contained in:
David Bomba 2021-10-11 13:19:38 +11:00
parent 9d551b6e1d
commit 543288c525
4 changed files with 19 additions and 6 deletions

View File

@ -380,11 +380,11 @@ class PreviewController extends BaseController
return $maker->getCompiledHTML();
}
if (config('ninja.phantomjs_pdf_generation')) {
if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
}
if(config('ninja.invoiceninja_hosted_pdf_generation')){
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
return (new NinjaPdf())->build($maker->getCompiledHTML(true));
}

View File

@ -89,9 +89,9 @@ class SystemHealth
public static function getPdfEngine()
{
if(config('ninja.invoiceninja_hosted_pdf_generation'))
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja')
return 'Invoice Ninja Hosted PDF Generator';
elseif(config('ninja.phantomjs_pdf_generation'))
elseif(config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom')
return 'Phantom JS Web Generator';
else
return 'SnapPDF PDF Generator';

View File

@ -713,6 +713,19 @@ trait GeneratesCounter
$replace[] = $client->id_number;
}
$search[] = '{$user_custom1}';
$replace[] = $entity->user->custom_value1;
$search[] = '{$user_custom2}';
$replace[] = $entity->user->custom_value2;
$search[] = '{$user_custom3}';
$replace[] = $entity->user->custom_value3;
$search[] = '{$client_custom4}';
$replace[] = $entity->user->custom_value4;
return str_replace($search, $replace, $pattern);
}
}

View File

@ -33,7 +33,8 @@ return [
'enabled_modules' => 32767,
'phantomjs_key' => env('PHANTOMJS_KEY', 'a-demo-key-with-low-quota-per-ip-address'),
'phantomjs_secret' => env('PHANTOMJS_SECRET', false),
'phantomjs_pdf_generation' => env('PHANTOMJS_PDF_GENERATION', true),
'phantomjs_pdf_generation' => env('PHANTOMJS_PDF_GENERATION', false),
'pdf_generator' => env('PDF_GENERATOR', false),
'trusted_proxies' => env('TRUSTED_PROXIES', false),
'is_docker' => env('IS_DOCKER', false),
'local_download' => env('LOCAL_DOWNLOAD', false),
@ -173,6 +174,5 @@ return [
'ninja_default_company_id' => env('NINJA_COMPANY_ID', null),
'ninja_default_company_gateway_id' => env('NINJA_COMPANY_GATEWAY_ID', null),
'ninja_hosted_secret' => env('NINJA_HOSTED_SECRET', null),
'pdf_generator' => env('PDF_GENERATOR', false),
'internal_queue_enabled' => env('INTERNAL_QUEUE_ENABLED', true),
];