Skip to content

Commit 938b0bb

Browse files
committed
Support typeset.sh v0.18
1 parent 4787e3d commit 938b0bb

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"minimum-stability": "stable",
1717
"require": {
1818
"laravel/framework": "^7.0 || ^8.0",
19-
"typesetsh/typesetsh": "^0.17"
19+
"typesetsh/typesetsh": "^0.18"
2020
},
2121
"require-dev": {
2222
"friendsofphp/php-cs-fixer": "^2.16"

config/typesetsh.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
|
2626
*/
2727

28-
'base_dir' => public_path(),
28+
'base_dir' => '/',
2929

3030
/*
3131
|--------------------------------------------------------------------------
@@ -74,4 +74,14 @@
7474
*/
7575

7676
'download_limit' => 1024 * 1024 * 5,
77+
78+
/*
79+
|--------------------------------------------------------------------------
80+
| Pdf Version
81+
|--------------------------------------------------------------------------
82+
|
83+
| PDF version to save the document in.
84+
*/
85+
86+
'pdf_version' => '1.4',
7787
];

src/ServiceProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ protected function registerPdfRenderer(): void
4141
$cacheDir = $app['config']['typesetsh.cache_dir'] ?? null;
4242
$timeout = (int)($app['config']['typesetsh.timeout'] ?? 15);
4343
$downloadLimit = (int)($app['config']['typesetsh.download_limit'] ?? 1024 * 1024 * 5);
44+
$pdfVersion = (string)($app['config']['typesetsh.pdf_version'] ?? '1.6');
4445

4546
$schemes = [];
4647
$schemes['data'] = new UriResolver\Data($cacheDir);
@@ -55,7 +56,7 @@ protected function registerPdfRenderer(): void
5556
$schemes['file'] = new UriResolver\File($allowedDirectories);
5657
}
5758

58-
return new Typesetsh(new UriResolver($schemes, $baseDir));
59+
return new Typesetsh(new UriResolver($schemes, $baseDir), null, $pdfVersion);
5960
});
6061

6162
$this->app->singleton('typesetsh.pdf', function ($app) {

src/Typesetsh.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,32 @@ class Typesetsh
2222
/** @var callable|UriResolver */
2323
private $uriResolver;
2424

25-
public function __construct(callable $uriResolver = null, HtmlToPdf $html2pdf = null)
25+
/** @var string */
26+
private $version;
27+
28+
public function __construct(callable $uriResolver = null, HtmlToPdf $html2pdf = null, string $version = '1.6')
2629
{
2730
$this->uriResolver = $uriResolver ?? UriResolver::httpOnly();
2831
$this->html2pdf = $html2pdf ?? new HtmlToPdf();
32+
$this->version = $version;
2933
}
3034

3135
public function render(string $html): Result
3236
{
33-
return $this->html2pdf->render($html, $this->uriResolver);
37+
$result = $this->html2pdf->render($html, $this->uriResolver);
38+
$result->version = $this->version;
39+
40+
return $result;
3441
}
3542

3643
/**
3744
* @param non-empty-list<string> $html
3845
*/
3946
public function renderMultiple(array $html): Result
4047
{
41-
return $this->html2pdf->renderMultiple($html, $this->uriResolver);
48+
$result = $this->html2pdf->renderMultiple($html, $this->uriResolver);
49+
$result->version = $this->version;
50+
51+
return $result;
4252
}
4353
}

0 commit comments

Comments
 (0)