-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #504 from KnpLabs/v2-unstable-wkhtmltopdf-global-o…
…ptions V2 unstable wkhtmltopdf global options
- Loading branch information
Showing
29 changed files
with
405 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Backend/WkHtmlToPdf/ExtraOption/ImageQualityOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class ImageQualityOption implements ExtraOption | ||
{ | ||
/** | ||
* @param positive-int $quality | ||
*/ | ||
public function __construct(public readonly int $quality) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--image-quality', $this->quality]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class LowQualityOption implements ExtraOption | ||
{ | ||
public function __construct() {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--lowquality']; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Backend/WkHtmlToPdf/ExtraOption/MarginBottomOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class MarginBottomOption implements ExtraOption | ||
{ | ||
public function __construct(public readonly string $margin) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--margin-bottom', $this->margin]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class MarginLeftOption implements ExtraOption | ||
{ | ||
public function __construct(public readonly string $margin) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--margin-left', $this->margin]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class MarginRightOption implements ExtraOption | ||
{ | ||
public function __construct(public readonly string $margin) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--margin-right', $this->margin]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class MarginTopOption implements ExtraOption | ||
{ | ||
public function __construct(public readonly string $margin) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--margin-top', $this->margin]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/Backend/WkHtmlToPdf/ExtraOption/NoPdfCompressionOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class NoPdfCompressionOption implements ExtraOption | ||
{ | ||
public function __construct() {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--no-pdf-compression']; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption\Orientation; | ||
|
||
enum Value: string | ||
{ | ||
case PORTRAIT = 'Portrait'; | ||
case LANDSCAPE = 'Landscape'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
use KNPLabs\Snappy\Core\Backend\Options\PageOrientation; | ||
|
||
final class OrientationOption implements ExtraOption | ||
{ | ||
public function __construct(private readonly ExtraOption\Orientation\Value $orientation) {} | ||
|
||
public static function fromPageOrientation(PageOrientation $pageOrientation): self | ||
{ | ||
return new self( | ||
match ($pageOrientation) { | ||
PageOrientation::PORTRAIT => ExtraOption\Orientation\Value::PORTRAIT, | ||
PageOrientation::LANDSCAPE => ExtraOption\Orientation\Value::LANDSCAPE, | ||
} | ||
); | ||
} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--orientation', $this->orientation->value]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class PageHeightOption implements ExtraOption | ||
{ | ||
public function __construct(public readonly string $height) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--page-height', $this->height]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class PageSizeOption implements ExtraOption | ||
{ | ||
public function __construct(public readonly string $size) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--page-size', $this->size]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class PageWidthOption implements ExtraOption | ||
{ | ||
public function __construct(public readonly string $width) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--page-width', $this->width]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class TitleOption implements ExtraOption | ||
{ | ||
public function __construct(public readonly string $title) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--title', $this->title]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption; | ||
|
||
final class UseXserverOption implements ExtraOption | ||
{ | ||
public function __construct() {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--use-xserver']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\OptionGroup; | ||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions\CollateOption; | ||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions\CookieJarOption; | ||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions\NoCollateOption; | ||
use KNPLabs\Snappy\Core\Backend\Options\PageOrientation; | ||
|
||
final class GlobalOptions extends OptionGroup | ||
{ | ||
public function __construct( | ||
public readonly ?CollateOption $collate, | ||
public readonly ?NoCollateOption $noCollate, | ||
public readonly ?CookieJarOption $cookieJar, | ||
public readonly ?PageOrientation $pageOrientation, | ||
) { | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Backend/WkHtmlToPdf/Options/GlobalOptions/CollateOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
use KNPLabs\Snappy\Backend\WkHtmlToPdf\Option; | ||
|
||
final class CollateOption implements Option | ||
{ | ||
public function __construct() {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--collate']; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Backend/WkHtmlToPdf/Options/GlobalOptions/CookieJarOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\Options\GlobalOptions; | ||
|
||
final class CookieJarOption | ||
{ | ||
public function __construct(public readonly string $path) {} | ||
|
||
public function compile(): array | ||
{ | ||
return ['--no-collate']; | ||
} | ||
} |
Oops, something went wrong.