diff --git a/.gitignore b/.gitignore index 362df57e1..83b754c04 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ _ide_helper.php /storage/debugbar .phpstorm.meta.php yarn.lock +/bin \ No newline at end of file diff --git a/app/Services/ExportService.php b/app/Services/ExportService.php index 14084d320..50ba75c17 100644 --- a/app/Services/ExportService.php +++ b/app/Services/ExportService.php @@ -1,6 +1,5 @@ $page, 'css' => $cssContent])->render(); + $useWKHTML = config('snappy.pdf.binary') !== false; $containedHtml = $this->containHtml($pageHtml); - $pdf = \PDF::loadHTML($containedHtml); + if ($useWKHTML) { + $pdf = \SnappyPDF::loadHTML($containedHtml); + } else { + $pdf = \PDF::loadHTML($containedHtml); + } return $pdf->output(); } diff --git a/composer.json b/composer.json index 7d4b5e62b..5a8fd67ae 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "league/flysystem-aws-s3-v3": "^1.0", "barryvdh/laravel-dompdf": "^0.7", "predis/predis": "^1.1", - "gathercontent/htmldiff": "^0.2.1" + "gathercontent/htmldiff": "^0.2.1", + "barryvdh/laravel-snappy": "^0.3.1" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index 74a090288..dcde9d9c6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "3124d900cfe857392a94de479f3ff6d4", - "content-hash": "a968767a73f77e66e865c276cf76eedf", + "hash": "2438a2f4a02adbea5f378f9e9408eb29", + "content-hash": "6add8bff71ecc86e0c90858590834a26", "packages": [ { "name": "aws/aws-sdk-php", @@ -255,6 +255,58 @@ ], "time": "2016-07-04 11:52:48" }, + { + "name": "barryvdh/laravel-snappy", + "version": "v0.3.1", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-snappy.git", + "reference": "509a4497be63d8ee7ff464a3daf00d9edde08e21" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-snappy/zipball/509a4497be63d8ee7ff464a3daf00d9edde08e21", + "reference": "509a4497be63d8ee7ff464a3daf00d9edde08e21", + "shasum": "" + }, + "require": { + "illuminate/filesystem": "5.0.x|5.1.x|5.2.x|5.3.x", + "illuminate/support": "5.0.x|5.1.x|5.2.x|5.3.x", + "knplabs/knp-snappy": "*", + "php": ">=5.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Snappy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Snappy PDF/Image for Laravel 4", + "keywords": [ + "image", + "laravel", + "pdf", + "snappy", + "wkhtmltoimage", + "wkhtmltopdf" + ], + "time": "2016-08-05 13:08:28" + }, { "name": "barryvdh/reflection-docblock", "version": "v2.0.4", @@ -997,6 +1049,71 @@ ], "time": "2015-12-05 17:17:57" }, + { + "name": "knplabs/knp-snappy", + "version": "0.4.3", + "source": { + "type": "git", + "url": "https://github.com/KnpLabs/snappy.git", + "reference": "44f7a9b37d5686fd7db4c1e9569a802a5d16923f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/KnpLabs/snappy/zipball/44f7a9b37d5686fd7db4c1e9569a802a5d16923f", + "reference": "44f7a9b37d5686fd7db4c1e9569a802a5d16923f", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/process": "~2.3|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.7" + }, + "suggest": { + "h4cc/wkhtmltoimage-amd64": "Provides wkhtmltoimage-amd64 binary for Linux-compatible machines, use version `~0.12` as dependency", + "h4cc/wkhtmltoimage-i386": "Provides wkhtmltoimage-i386 binary for Linux-compatible machines, use version `~0.12` as dependency", + "h4cc/wkhtmltopdf-amd64": "Provides wkhtmltopdf-amd64 binary for Linux-compatible machines, use version `~0.12` as dependency", + "h4cc/wkhtmltopdf-i386": "Provides wkhtmltopdf-i386 binary for Linux-compatible machines, use version `~0.12` as dependency", + "wemersonjanuario/wkhtmltopdf-windows": "Provides wkhtmltopdf executable for Windows, use version `~0.12` as dependency" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Knp\\Snappy": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "KNPLabs Team", + "homepage": "http://knplabs.com" + }, + { + "name": "Symfony Community", + "homepage": "http://github.com/KnpLabs/snappy/contributors" + } + ], + "description": "PHP5 library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage.", + "homepage": "http://github.com/KnpLabs/snappy", + "keywords": [ + "knp", + "knplabs", + "pdf", + "snapshot", + "thumbnail", + "wkhtmltopdf" + ], + "time": "2015-11-17 13:16:27" + }, { "name": "laravel/framework", "version": "v5.3.11", diff --git a/config/app.php b/config/app.php index 786f005ac..0c3e1e71c 100644 --- a/config/app.php +++ b/config/app.php @@ -148,6 +148,7 @@ return [ Barryvdh\DomPDF\ServiceProvider::class, Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, Barryvdh\Debugbar\ServiceProvider::class, + Barryvdh\Snappy\ServiceProvider::class, /* @@ -218,6 +219,7 @@ return [ 'ImageTool' => Intervention\Image\Facades\Image::class, 'PDF' => Barryvdh\DomPDF\Facade::class, + 'SnappyPDF' => Barryvdh\Snappy\Facades\SnappyPdf::class, 'Debugbar' => Barryvdh\Debugbar\Facade::class, /** diff --git a/config/snappy.php b/config/snappy.php new file mode 100644 index 000000000..73f21fd30 --- /dev/null +++ b/config/snappy.php @@ -0,0 +1,18 @@ + [ + 'enabled' => true, + 'binary' => file_exists(base_path('wkhtmltopdf')) ? base_path('wkhtmltopdf') : env('WKHTMLTOPDF', false), + 'timeout' => false, + 'options' => [], + 'env' => [], + ], + 'image' => [ + 'enabled' => false, + 'binary' => '/usr/local/bin/wkhtmltoimage', + 'timeout' => false, + 'options' => [], + 'env' => [], + ], +]; diff --git a/resources/assets/sass/_forms.scss b/resources/assets/sass/_forms.scss index 62a7b4001..7e6b800d2 100644 --- a/resources/assets/sass/_forms.scss +++ b/resources/assets/sass/_forms.scss @@ -33,7 +33,7 @@ position: relative; z-index: 5; textarea { - font-family: 'Roboto Mono'; + font-family: 'Roboto Mono', monospace; font-style: normal; font-weight: 400; padding: $-xs $-m; @@ -55,6 +55,7 @@ display: flex; flex-direction: column; border: 1px solid #DDD; + width: 50%; } .markdown-display { padding: 0 $-m 0; @@ -68,7 +69,7 @@ .editor-toolbar { width: 100%; padding: $-xs $-m; - font-family: 'Roboto Mono'; + font-family: 'Roboto Mono', monospace; font-size: 11px; line-height: 1.6; border-bottom: 1px solid #DDD; diff --git a/resources/views/pages/revisions.blade.php b/resources/views/pages/revisions.blade.php index 3549f5f05..3b9812abd 100644 --- a/resources/views/pages/revisions.blade.php +++ b/resources/views/pages/revisions.blade.php @@ -45,7 +45,7 @@ @else {{ trans('entities.pages_revisions_preview') }}  |  - {{ trans('entities.pages_revisions_restore') }} + {{ trans('entities.pages_revisions_restore') }} @endif