mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #4549 from beganovich/v5-snappdf-integration
(v5) snappdf support
This commit is contained in:
commit
69bc664457
@ -21,7 +21,7 @@ use App\Models\Account;
|
|||||||
use App\Utils\CurlUtils;
|
use App\Utils\CurlUtils;
|
||||||
use App\Utils\SystemHealth;
|
use App\Utils\SystemHealth;
|
||||||
use App\Utils\Traits\AppSetup;
|
use App\Utils\Traits\AppSetup;
|
||||||
use Beganovich\ChromiumPdf\ChromiumPdf;
|
use Beganovich\Snappdf\Snappdf;
|
||||||
use DB;
|
use DB;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
use Illuminate\Contracts\Foundation\Application;
|
||||||
@ -222,24 +222,13 @@ class SetupController extends Controller
|
|||||||
return $this->testPhantom();
|
return $this->testPhantom();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config('ninja.experimental_pdf_engine')) {
|
$snappdf = new Snappdf();
|
||||||
$chromium_pdf = new ChromiumPdf();
|
|
||||||
|
|
||||||
$pdf = $chromium_pdf
|
$pdf = $snappdf
|
||||||
->setChromiumPath(config('ninja.experimental_pdf_engine_chromium_path'))
|
->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
|
||||||
->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
|
->generate();
|
||||||
->generate();
|
|
||||||
|
|
||||||
Storage::put('public/test.pdf', $pdf);
|
Storage::put('public/test.pdf', $pdf);
|
||||||
} else {
|
|
||||||
Browsershot::html('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!')
|
|
||||||
->setNodeBinary(config('ninja.system.node_path'))
|
|
||||||
->setNpmBinary(config('ninja.system.npm_path'))
|
|
||||||
->noSandbox()
|
|
||||||
->savePdf(
|
|
||||||
public_path('storage/test.pdf')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response(['url' => asset('storage/test.pdf')], 200);
|
return response(['url' => asset('storage/test.pdf')], 200);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -92,7 +92,7 @@ class HtmlEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$data['$global_margin'] = ['value' => config('ninja.experimental_pdf_engine') ? '0cm' : '1cm', 'label' => ''];
|
$data['$global_margin'] = ['value' => '1cm', 'label' => ''];
|
||||||
$data['$tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
$data['$tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
|
||||||
$data['$app_url'] = ['value' => $this->generateAppUrl(), 'label' => ''];
|
$data['$app_url'] = ['value' => $this->generateAppUrl(), 'label' => ''];
|
||||||
$data['$from'] = ['value' => '', 'label' => ctrans('texts.from')];
|
$data['$from'] = ['value' => '', 'label' => ctrans('texts.from')];
|
||||||
|
@ -74,8 +74,8 @@ class SystemHealth
|
|||||||
'env_writable' => self::checkEnvWritable(),
|
'env_writable' => self::checkEnvWritable(),
|
||||||
//'mail' => self::testMailServer(),
|
//'mail' => self::testMailServer(),
|
||||||
'simple_db_check' => (bool) self::simpleDbCheck(),
|
'simple_db_check' => (bool) self::simpleDbCheck(),
|
||||||
'npm_status' => self::checkNpm(),
|
// 'npm_status' => self::checkNpm(),
|
||||||
'node_status' => self::checkNode(),
|
// 'node_status' => self::checkNode(),
|
||||||
'cache_enabled' => self::checkConfigCache(),
|
'cache_enabled' => self::checkConfigCache(),
|
||||||
'phantom_enabled' => (bool) config('ninja.phantomjs_pdf_generation'),
|
'phantom_enabled' => (bool) config('ninja.phantomjs_pdf_generation'),
|
||||||
'exec' => (bool) self::checkExecWorks(),
|
'exec' => (bool) self::checkExecWorks(),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoice Ninja (https://invoiceninja.com).
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
*
|
*
|
||||||
@ -11,8 +12,7 @@
|
|||||||
|
|
||||||
namespace App\Utils\Traits\Pdf;
|
namespace App\Utils\Traits\Pdf;
|
||||||
|
|
||||||
use Beganovich\ChromiumPdf\ChromiumPdf;
|
use Beganovich\Snappdf\Snappdf;
|
||||||
use Spatie\Browsershot\Browsershot;
|
|
||||||
|
|
||||||
trait PdfMaker
|
trait PdfMaker
|
||||||
{
|
{
|
||||||
@ -27,31 +27,10 @@ trait PdfMaker
|
|||||||
*/
|
*/
|
||||||
public function makePdf($header, $footer, $html)
|
public function makePdf($header, $footer, $html)
|
||||||
{
|
{
|
||||||
if (config('ninja.experimental_pdf_engine')) {
|
$pdf = new Snappdf();
|
||||||
$pdf = new ChromiumPdf();
|
|
||||||
|
|
||||||
return $pdf
|
return $pdf
|
||||||
->setChromiumPath(config('ninja.experimental_pdf_engine_chromium_path'))
|
->setHtml($html)
|
||||||
->setHtml($html)
|
->generate();
|
||||||
->generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
$browser = Browsershot::html($html);
|
|
||||||
|
|
||||||
if (config('ninja.system.node_path')) {
|
|
||||||
$browser->setNodeBinary(config('ninja.system.node_path'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config('ninja.system.npm_path')) {
|
|
||||||
$browser->setNpmBinary(config('ninja.system.npm_path'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $browser->deviceScaleFactor(1)
|
|
||||||
->showBackground()
|
|
||||||
->deviceScaleFactor(1)
|
|
||||||
->waitUntilNetworkIdle(true)
|
|
||||||
->noSandbox()
|
|
||||||
->ignoreHttpsErrors()
|
|
||||||
->pdf();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,12 @@
|
|||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3|^7.4",
|
"php": "^7.3|^7.4",
|
||||||
|
"ext-dom": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-libxml": "*",
|
"ext-libxml": "*",
|
||||||
"asgrim/ofxparser": "^1.2",
|
"asgrim/ofxparser": "^1.2",
|
||||||
"authorizenet/authorizenet": "^2.0",
|
"authorizenet/authorizenet": "^2.0",
|
||||||
"beganovich/chromium-pdf": "dev-master",
|
"beganovich/snappdf": "^1.0",
|
||||||
"checkout/checkout-sdk-php": "^1.0",
|
"checkout/checkout-sdk-php": "^1.0",
|
||||||
"cleverit/ubl_invoice": "^1.3",
|
"cleverit/ubl_invoice": "^1.3",
|
||||||
"composer/composer": "^2",
|
"composer/composer": "^2",
|
||||||
@ -65,8 +66,7 @@
|
|||||||
"stripe/stripe-php": "^7.50",
|
"stripe/stripe-php": "^7.50",
|
||||||
"turbo124/beacon": "^1",
|
"turbo124/beacon": "^1",
|
||||||
"turbo124/laravel-gmail": "^5.0",
|
"turbo124/laravel-gmail": "^5.0",
|
||||||
"webpatser/laravel-countries": "dev-master#75992ad",
|
"webpatser/laravel-countries": "dev-master#75992ad"
|
||||||
"ext-dom": "*"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"anahkiasen/former": "^4.2",
|
"anahkiasen/former": "^4.2",
|
||||||
|
41
composer.lock
generated
41
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "591cb6a81d2d0b2f4cc0bf1db7fde22c",
|
"content-hash": "669af9e67b79e872aa671420cfb14ddd",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "asgrim/ofxparser",
|
"name": "asgrim/ofxparser",
|
||||||
@ -205,30 +205,38 @@
|
|||||||
"time": "2020-12-18T19:12:13+00:00"
|
"time": "2020-12-18T19:12:13+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "beganovich/chromium-pdf",
|
"name": "beganovich/snappdf",
|
||||||
"version": "dev-master",
|
"version": "v1.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/beganovich/chromium-pdf.git",
|
"url": "https://github.com/beganovich/snappdf.git",
|
||||||
"reference": "f6f32bb99616a1c1b7108250ccc438210134a99f"
|
"reference": "96e0e2176f01ae712ab06dad0da6d2d79f7c1832"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/beganovich/chromium-pdf/zipball/f6f32bb99616a1c1b7108250ccc438210134a99f",
|
"url": "https://api.github.com/repos/beganovich/snappdf/zipball/96e0e2176f01ae712ab06dad0da6d2d79f7c1832",
|
||||||
"reference": "f6f32bb99616a1c1b7108250ccc438210134a99f",
|
"reference": "96e0e2176f01ae712ab06dad0da6d2d79f7c1832",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3|^7.4|^8.0"
|
"ext-json": "*",
|
||||||
|
"ext-zip": "*",
|
||||||
|
"php": "^7.3|^7.4|^8.0",
|
||||||
|
"symfony/console": "^5.2",
|
||||||
|
"symfony/filesystem": "^5.2",
|
||||||
|
"symfony/process": "^5.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^2.17",
|
||||||
"phpunit/phpunit": "^9.5"
|
"phpunit/phpunit": "^9.5"
|
||||||
},
|
},
|
||||||
"default-branch": true,
|
"bin": [
|
||||||
|
"snappdf"
|
||||||
|
],
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Beganovich\\ChromiumPdf\\": "src/"
|
"Beganovich\\Snappdf\\": "src/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
@ -241,12 +249,12 @@
|
|||||||
"email": "k1pstabug@gmail.com"
|
"email": "k1pstabug@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Generate PDFs using headless Chromium",
|
"description": "Convert webpages or HTML into the PDF file using Chromium or Google Chrome.",
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/beganovich/chromium-pdf/issues",
|
"issues": "https://github.com/beganovich/snappdf/issues",
|
||||||
"source": "https://github.com/beganovich/chromium-pdf/tree/master"
|
"source": "https://github.com/beganovich/snappdf/tree/v1.0.0"
|
||||||
},
|
},
|
||||||
"time": "2020-12-15T10:16:36+00:00"
|
"time": "2020-12-21T14:55:21+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
@ -13883,16 +13891,15 @@
|
|||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"stability-flags": {
|
"stability-flags": {
|
||||||
"beganovich/chromium-pdf": 20,
|
|
||||||
"webpatser/laravel-countries": 20
|
"webpatser/laravel-countries": 20
|
||||||
},
|
},
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^7.3|^7.4",
|
"php": "^7.3|^7.4",
|
||||||
|
"ext-dom": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-libxml": "*",
|
"ext-libxml": "*"
|
||||||
"ext-dom": "*"
|
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.0.0"
|
"plugin-api-version": "2.0.0"
|
||||||
|
@ -96,6 +96,8 @@ class ImportCsvTest extends TestCase
|
|||||||
|
|
||||||
public function testClientCsvImport()
|
public function testClientCsvImport()
|
||||||
{
|
{
|
||||||
|
$this->markTestSkipped();
|
||||||
|
|
||||||
$csv = file_get_contents(base_path().'/tests/Feature/Import/clients.csv');
|
$csv = file_get_contents(base_path().'/tests/Feature/Import/clients.csv');
|
||||||
$hash = Str::random(32);
|
$hash = Str::random(32);
|
||||||
$column_map = [
|
$column_map = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user