File tree Expand file tree Collapse file tree 9 files changed +31
-24
lines changed Expand file tree Collapse file tree 9 files changed +31
-24
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ Alternative you can use the helper.
4848Route::get('/invoice/print', function () {
4949 $invoice = new stdClass();
5050
51- return typesetsh \pdf('invoice', ['invoice' => $invoice]);
51+ return Typesetsh \pdf('invoice', ['invoice' => $invoice]);
5252});
5353```
5454
@@ -59,7 +59,7 @@ or force a download
5959Route::get('/invoice/print', function () {
6060 $invoice = new stdClass();
6161
62- return typesetsh \pdf('invoice', ['invoice' => $invoice])->forceDownload('invoice.pdf');
62+ return Typesetsh \pdf('invoice', ['invoice' => $invoice])->forceDownload('invoice.pdf');
6363});
6464```
6565
Original file line number Diff line number Diff line change 1616 "minimum-stability" : " stable" ,
1717 "require" : {
1818 "laravel/framework" : " ^7.0 || ^8.0" ,
19- "typesetsh/typesetsh" : " ^0.15 "
19+ "typesetsh/typesetsh" : " ^0.16 "
2020 },
2121 "require-dev" : {
2222 "friendsofphp/php-cs-fixer" : " ^2.16"
Original file line number Diff line number Diff line change 5151 */
5252
5353 'timeout ' => 15 ,
54+
55+ /*
56+ |--------------------------------------------------------------------------
57+ | Download Limit
58+ |--------------------------------------------------------------------------
59+ |
60+ | Max file-size when downloading remote resources. Only works when ext-curl
61+ | is available.
62+ |
63+ */
64+
65+ 'download_limit ' => 1024 * 1024 * 5 ,
5466];
Original file line number Diff line number Diff line change 33 * Copyright (c) 2020 Jacob Siefer
44 * See LICENSE bundled with this package for license details.
55 */
6-
76declare (strict_types=1 );
87
98namespace Typesetsh \LaravelWrapper \Facades ;
Original file line number Diff line number Diff line change 33 * Copyright (c) 2020 Jacob Siefer
44 * See LICENSE bundled with this package for license details.
55 */
6-
76declare (strict_types=1 );
87
98namespace Typesetsh \LaravelWrapper \Pdf ;
Original file line number Diff line number Diff line change 33 * Copyright (c) 2020 Jacob Siefer
44 * See LICENSE bundled with this package for license details.
55 */
6-
76declare (strict_types=1 );
87
98namespace Typesetsh \LaravelWrapper \Pdf ;
Original file line number Diff line number Diff line change 33 * Copyright (c) 2020 Jacob Siefer
44 * See LICENSE bundled with this package for license details.
55 */
6-
76declare (strict_types=1 );
87
98namespace Typesetsh \LaravelWrapper ;
109
11- use Illuminate \Contracts \ Support \ DeferrableProvider ;
10+ use Illuminate \Contracts ;
1211use Illuminate \Support ;
13- use typesetsh \UriResolver ;
12+ use Typesetsh \UriResolver ;
1413
15- class ServiceProvider extends Support \ServiceProvider implements DeferrableProvider
14+ class ServiceProvider extends Support \ServiceProvider implements Contracts \ Support \ DeferrableProvider
1615{
1716 const CONFIG_PATH = __DIR__ .'/../config/typesetsh.php ' ;
1817
@@ -39,11 +38,14 @@ protected function registerPdfRenderer(): void
3938 $ allowedDirectories = $ app ['config ' ]['typesetsh.allowed_directories ' ] ?? [];
4039 $ allowProtocols = $ app ['config ' ]['typesetsh.allowed_protocols ' ] ?? [];
4140 $ cacheDir = $ app ['config ' ]['typesetsh.cache_dir ' ] ?? null ;
42- $ timeout = $ app ['config ' ]['typesetsh.timeout ' ] ?? 15 ;
41+ $ timeout = (int )($ app ['config ' ]['typesetsh.timeout ' ] ?? 15 );
42+ $ downloadLimit = (int )($ app ['config ' ]['typesetsh.download_limit ' ] ?? 1024 * 1024 * 5 );
4343
4444 $ schemes = [];
45+ $ schemes ['data ' ] = new UriResolver \Data ($ cacheDir );
46+
4547 if ($ allowProtocols ) {
46- $ http = new UriResolver \Http ($ cacheDir , $ timeout );
48+ $ http = new UriResolver \Http ($ cacheDir , $ timeout, $ downloadLimit );
4749 foreach ($ allowProtocols as $ protocol ) {
4850 $ schemes [$ protocol ] = $ http ;
4951 }
Original file line number Diff line number Diff line change 33 * Copyright (c) 2020 Jacob Siefer
44 * See LICENSE bundled with this package for license details.
55 */
6-
76declare (strict_types=1 );
87
98namespace Typesetsh \LaravelWrapper ;
109
11- use typesetsh \HtmlToPdf ;
12- use typesetsh \Result ;
13- use typesetsh \UriResolver ;
10+ use Typesetsh \HtmlToPdf ;
11+ use Typesetsh \Result ;
12+ use Typesetsh \UriResolver ;
1413
1514/**
1615 * Typeset.sh pdf wrapper with a pre provided uri resolver.
1716 */
1817class Typesetsh
1918{
20- /**
21- * @var HtmlToPdf
22- */
19+ /** @var HtmlToPdf */
2320 private $ html2pdf ;
2421
25- /**
26- * @var callable|UriResolver
27- */
22+ /** @var callable|UriResolver */
2823 private $ uriResolver ;
2924
3025 public function __construct (callable $ uriResolver = null , HtmlToPdf $ html2pdf = null )
@@ -39,7 +34,7 @@ public function render(string $html): Result
3934 }
4035
4136 /**
42- * @param string[] $html
37+ * @param non-empty-list< string> $html
4338 */
4439 public function renderMultiple (array $ html ): Result
4540 {
Original file line number Diff line number Diff line change 33 * Copyright (c) 2020 Jacob Siefer
44 * See LICENSE bundled with this package for license details.
55 */
6+ declare (strict_types=1 );
67
7- namespace typesetsh ;
8+ namespace Typesetsh ;
89
910use Typesetsh \LaravelWrapper \Pdf ;
1011
You can’t perform that action at this time.
0 commit comments