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.
48
48
Route::get('/invoice/print', function () {
49
49
$invoice = new stdClass();
50
50
51
- return typesetsh \pdf('invoice', ['invoice' => $invoice]);
51
+ return Typesetsh \pdf('invoice', ['invoice' => $invoice]);
52
52
});
53
53
```
54
54
@@ -59,7 +59,7 @@ or force a download
59
59
Route::get('/invoice/print', function () {
60
60
$invoice = new stdClass();
61
61
62
- return typesetsh \pdf('invoice', ['invoice' => $invoice])->forceDownload('invoice.pdf');
62
+ return Typesetsh \pdf('invoice', ['invoice' => $invoice])->forceDownload('invoice.pdf');
63
63
});
64
64
```
65
65
Original file line number Diff line number Diff line change 16
16
"minimum-stability" : " stable" ,
17
17
"require" : {
18
18
"laravel/framework" : " ^7.0 || ^8.0" ,
19
- "typesetsh/typesetsh" : " ^0.15 "
19
+ "typesetsh/typesetsh" : " ^0.16 "
20
20
},
21
21
"require-dev" : {
22
22
"friendsofphp/php-cs-fixer" : " ^2.16"
Original file line number Diff line number Diff line change 51
51
*/
52
52
53
53
'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 ,
54
66
];
Original file line number Diff line number Diff line change 3
3
* Copyright (c) 2020 Jacob Siefer
4
4
* See LICENSE bundled with this package for license details.
5
5
*/
6
-
7
6
declare (strict_types=1 );
8
7
9
8
namespace Typesetsh \LaravelWrapper \Facades ;
Original file line number Diff line number Diff line change 3
3
* Copyright (c) 2020 Jacob Siefer
4
4
* See LICENSE bundled with this package for license details.
5
5
*/
6
-
7
6
declare (strict_types=1 );
8
7
9
8
namespace Typesetsh \LaravelWrapper \Pdf ;
Original file line number Diff line number Diff line change 3
3
* Copyright (c) 2020 Jacob Siefer
4
4
* See LICENSE bundled with this package for license details.
5
5
*/
6
-
7
6
declare (strict_types=1 );
8
7
9
8
namespace Typesetsh \LaravelWrapper \Pdf ;
Original file line number Diff line number Diff line change 3
3
* Copyright (c) 2020 Jacob Siefer
4
4
* See LICENSE bundled with this package for license details.
5
5
*/
6
-
7
6
declare (strict_types=1 );
8
7
9
8
namespace Typesetsh \LaravelWrapper ;
10
9
11
- use Illuminate \Contracts \ Support \ DeferrableProvider ;
10
+ use Illuminate \Contracts ;
12
11
use Illuminate \Support ;
13
- use typesetsh \UriResolver ;
12
+ use Typesetsh \UriResolver ;
14
13
15
- class ServiceProvider extends Support \ServiceProvider implements DeferrableProvider
14
+ class ServiceProvider extends Support \ServiceProvider implements Contracts \ Support \ DeferrableProvider
16
15
{
17
16
const CONFIG_PATH = __DIR__ .'/../config/typesetsh.php ' ;
18
17
@@ -39,11 +38,14 @@ protected function registerPdfRenderer(): void
39
38
$ allowedDirectories = $ app ['config ' ]['typesetsh.allowed_directories ' ] ?? [];
40
39
$ allowProtocols = $ app ['config ' ]['typesetsh.allowed_protocols ' ] ?? [];
41
40
$ 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 );
43
43
44
44
$ schemes = [];
45
+ $ schemes ['data ' ] = new UriResolver \Data ($ cacheDir );
46
+
45
47
if ($ allowProtocols ) {
46
- $ http = new UriResolver \Http ($ cacheDir , $ timeout );
48
+ $ http = new UriResolver \Http ($ cacheDir , $ timeout, $ downloadLimit );
47
49
foreach ($ allowProtocols as $ protocol ) {
48
50
$ schemes [$ protocol ] = $ http ;
49
51
}
Original file line number Diff line number Diff line change 3
3
* Copyright (c) 2020 Jacob Siefer
4
4
* See LICENSE bundled with this package for license details.
5
5
*/
6
-
7
6
declare (strict_types=1 );
8
7
9
8
namespace Typesetsh \LaravelWrapper ;
10
9
11
- use typesetsh \HtmlToPdf ;
12
- use typesetsh \Result ;
13
- use typesetsh \UriResolver ;
10
+ use Typesetsh \HtmlToPdf ;
11
+ use Typesetsh \Result ;
12
+ use Typesetsh \UriResolver ;
14
13
15
14
/**
16
15
* Typeset.sh pdf wrapper with a pre provided uri resolver.
17
16
*/
18
17
class Typesetsh
19
18
{
20
- /**
21
- * @var HtmlToPdf
22
- */
19
+ /** @var HtmlToPdf */
23
20
private $ html2pdf ;
24
21
25
- /**
26
- * @var callable|UriResolver
27
- */
22
+ /** @var callable|UriResolver */
28
23
private $ uriResolver ;
29
24
30
25
public function __construct (callable $ uriResolver = null , HtmlToPdf $ html2pdf = null )
@@ -39,7 +34,7 @@ public function render(string $html): Result
39
34
}
40
35
41
36
/**
42
- * @param string[] $html
37
+ * @param non-empty-list< string> $html
43
38
*/
44
39
public function renderMultiple (array $ html ): Result
45
40
{
Original file line number Diff line number Diff line change 3
3
* Copyright (c) 2020 Jacob Siefer
4
4
* See LICENSE bundled with this package for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
- namespace typesetsh ;
8
+ namespace Typesetsh ;
8
9
9
10
use Typesetsh \LaravelWrapper \Pdf ;
10
11
You can’t perform that action at this time.
0 commit comments