diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php
index 3841cda5f5e8..e86e503deec9 100644
--- a/app/Utils/HtmlEngine.php
+++ b/app/Utils/HtmlEngine.php
@@ -92,8 +92,7 @@ class HtmlEngine
}
$data = [];
- $data['$global-margin'] = ['value' => 'm-8', 'label' => ''];
- $data['$global-padding'] = ['value' => 'p-8', 'label' => ''];
+ $data['$global-margin'] = ['value' => config('ninja.experimental_pdf_engine') ? '0cm' : '1cm', 'label' => ''];
$data['$tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
$data['$app_url'] = ['value' => $this->generateAppUrl(), 'label' => ''];
$data['$from'] = ['value' => '', 'label' => ctrans('texts.from')];
@@ -155,7 +154,7 @@ class HtmlEngine
} else {
$data['$balance_due'] = ['value' => Number::formatMoney($this->entity->balance, $this->client) ?: ' ', 'label' => ctrans('texts.balance_due')];
}
-
+
$data['$quote.balance_due'] = $data['$balance_due'];
$data['$invoice.balance_due'] = $data['$balance_due'];
$data['$balance_due'] = $data['$balance_due'];
@@ -243,7 +242,7 @@ class HtmlEngine
$data['$client.postal_city_state'] = &$data['$postal_city_state'];
$data['$client.country'] = &$data['$country'];
$data['$client.email'] = &$data['$email'];
-
+
$data['$client.currency'] = ['value' => $this->client->currency()->code, 'label' => ''];
$data['$client.balance'] = ['value' => Number::formatMoney($this->client->balance, $this->client), 'label' => ctrans('texts.account_balance')];
diff --git a/app/Utils/Traits/Pdf/PdfMaker.php b/app/Utils/Traits/Pdf/PdfMaker.php
index 25fd6ef59437..d7c23960e76c 100644
--- a/app/Utils/Traits/Pdf/PdfMaker.php
+++ b/app/Utils/Traits/Pdf/PdfMaker.php
@@ -11,6 +11,7 @@
namespace App\Utils\Traits\Pdf;
+use Beganovich\ChromiumPdf\ChromiumPdf;
use Spatie\Browsershot\Browsershot;
trait PdfMaker
@@ -26,6 +27,15 @@ trait PdfMaker
*/
public function makePdf($header, $footer, $html)
{
+ if (config('ninja.experimental_pdf_engine')) {
+ $pdf = new ChromiumPdf();
+
+ return $pdf
+ ->setChromiumPath(config('ninja.experimental_pdf_engine_chromium_path'))
+ ->setHtml($html)
+ ->generate();
+ }
+
$browser = Browsershot::html($html);
if (config('ninja.system.node_path')) {
diff --git a/composer.json b/composer.json
index 852cc0ceb6e5..fdcd1945ef31 100644
--- a/composer.json
+++ b/composer.json
@@ -29,6 +29,7 @@
"ext-json": "*",
"asgrim/ofxparser": "^1.2",
"authorizenet/authorizenet": "^2.0",
+ "beganovich/chromium-pdf": "dev-master",
"checkout/checkout-sdk-php": "^1.0",
"cleverit/ubl_invoice": "^1.3",
"composer/composer": "^2",
diff --git a/composer.lock b/composer.lock
index 578bffb04798..f8f336f200ed 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "35318cb6b03b84487f53dc09f2262030",
+ "content-hash": "75cb7287f45830678381d8e27486cf4a",
"packages": [
{
"name": "asgrim/ofxparser",
@@ -204,6 +204,50 @@
},
"time": "2020-12-11T19:12:18+00:00"
},
+ {
+ "name": "beganovich/chromium-pdf",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/beganovich/chromium-pdf.git",
+ "reference": "0f1641f0f8272b68aa4942307b85fba5596a90c3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/beganovich/chromium-pdf/zipball/0f1641f0f8272b68aa4942307b85fba5596a90c3",
+ "reference": "0f1641f0f8272b68aa4942307b85fba5596a90c3",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.3|^7.4|^8.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.5"
+ },
+ "default-branch": true,
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Beganovich\\ChromiumPdf\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Benjamin Beganović",
+ "email": "k1pstabug@gmail.com"
+ }
+ ],
+ "description": "Generate PDFs using headless Chromium",
+ "support": {
+ "issues": "https://github.com/beganovich/chromium-pdf/issues",
+ "source": "https://github.com/beganovich/chromium-pdf/tree/master"
+ },
+ "time": "2020-12-14T15:49:17+00:00"
+ },
{
"name": "brick/math",
"version": "0.9.1",
@@ -13836,6 +13880,7 @@
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {
+ "beganovich/chromium-pdf": 20,
"webpatser/laravel-countries": 20
},
"prefer-stable": true,
diff --git a/config/ninja.php b/config/ninja.php
index af59f5edb060..6119bfb3365b 100644
--- a/config/ninja.php
+++ b/config/ninja.php
@@ -32,7 +32,7 @@ return [
'phantomjs_secret' => env('PHANTOMJS_SECRET', false),
'phantomjs_pdf_generation' => env('PHANTOMJS_PDF_GENERATION', true),
'trusted_proxies' => env('TRUSTED_PROXIES', false),
-
+
'sentry_dsn' => env('SENTRY_LARAVEL_DSN', 'https://9b4e15e575214354a7d666489783904a@sentry.invoicing.co/6'),
'environment' => env('NINJA_ENVIRONMENT', 'selfhost'), // 'hosted', 'development', 'selfhost', 'reseller'
@@ -135,4 +135,6 @@ return [
'designs' => [
'base_path' => resource_path('views/pdf-designs/'),
],
+ 'experimental_pdf_engine' => env('EXPERIMENTAL_PDF_ENGINE', false),
+ 'experimental_pdf_engine_chromium_path' => env('EXPERIMENTAL_PDF_ENGINE_CHROMIUM_PATH', null),
];
diff --git a/resources/views/pdf-designs/bold.html b/resources/views/pdf-designs/bold.html
index 4090a44c163d..a3c4fd17847f 100644
--- a/resources/views/pdf-designs/bold.html
+++ b/resources/views/pdf-designs/bold.html
@@ -14,6 +14,7 @@
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-family: Arial, Helvetica, sans-serif;
+ margin: "$global-margin";
}
p {
diff --git a/resources/views/pdf-designs/business.html b/resources/views/pdf-designs/business.html
index ff23b04d46cc..f29891db96c3 100644
--- a/resources/views/pdf-designs/business.html
+++ b/resources/views/pdf-designs/business.html
@@ -12,7 +12,7 @@
}
@page {
- margin: 1cm;
+ margin: "$global-margin";
}
p {
diff --git a/resources/views/pdf-designs/clean.html b/resources/views/pdf-designs/clean.html
index 9bf61d599ac8..28cfeabcaf1f 100644
--- a/resources/views/pdf-designs/clean.html
+++ b/resources/views/pdf-designs/clean.html
@@ -9,7 +9,7 @@
-moz-osx-font-smoothing: grayscale;
font-family: Arial, Helvetica, sans-serif;
font-size: "$font_size";
- margin: 1cm;
+ margin: "$global-margin";
}
p {
diff --git a/resources/views/pdf-designs/creative.html b/resources/views/pdf-designs/creative.html
index 03e3489dcf08..5aa384ccae97 100644
--- a/resources/views/pdf-designs/creative.html
+++ b/resources/views/pdf-designs/creative.html
@@ -30,7 +30,7 @@
}
body {
- margin: 2rem;
+ margin: "$global-margin";
}
.header-wrapper {
diff --git a/resources/views/pdf-designs/elegant.html b/resources/views/pdf-designs/elegant.html
index 35342cfa65be..7686f5f22547 100644
--- a/resources/views/pdf-designs/elegant.html
+++ b/resources/views/pdf-designs/elegant.html
@@ -17,7 +17,7 @@
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-family: Arial, Helvetica, sans-serif;
- margin: 1cm;
+ margin: "$global-margin";
}
.company-logo-wrapper {
diff --git a/resources/views/pdf-designs/hipster.html b/resources/views/pdf-designs/hipster.html
index 8f482848189f..42b6322bff98 100644
--- a/resources/views/pdf-designs/hipster.html
+++ b/resources/views/pdf-designs/hipster.html
@@ -20,7 +20,7 @@
}
@page {
- margin: 1cm;
+ margin: "$global-margin";
}
.header-wrapper {
diff --git a/resources/views/pdf-designs/plain.html b/resources/views/pdf-designs/plain.html
index 6384395e8d06..c72398f9fc9a 100644
--- a/resources/views/pdf-designs/plain.html
+++ b/resources/views/pdf-designs/plain.html
@@ -13,7 +13,7 @@
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-family: Arial, Helvetica, sans-serif;
- margin: 1cm;
+ margin: "$global-margin";
}
.header-wrapper {
@@ -58,8 +58,8 @@
flex-direction: column;
}
- #product-table,
- #delivery-note-table,
+ #product-table,
+ #delivery-note-table,
#task-table {
min-width: 100%;
table-layout: fixed;
diff --git a/resources/views/pdf-designs/playful.html b/resources/views/pdf-designs/playful.html
index 95c9f3d2ac2c..96516134d99e 100644
--- a/resources/views/pdf-designs/playful.html
+++ b/resources/views/pdf-designs/playful.html
@@ -17,7 +17,7 @@
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-family: Arial, Helvetica, sans-serif;
- margin: 1cm;
+ margin: "$global-margin";
}
.header-wrapper {