Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement wkhtmltopdf backend headers and footers options #507

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace KNPLabs\Snappy\Backend\WkHtmlToPdf;

interface ExtraOption {
public function isRepeatable(): bool;

/** @return array<string|int|float> */
public function compile(): array;
}
5 changes: 5 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/CookieJarOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ final class CookieJarOption implements ExtraOption
{
public function __construct(public readonly string $path) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--no-collate'];
Expand Down
5 changes: 5 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/CopiesOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ final class CopiesOption implements ExtraOption
*/
public function __construct(private readonly int $number) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--copies', $this->number];
Expand Down
5 changes: 5 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/DpiOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ final class DpiOptions implements ExtraOption
*/
public function __construct(private readonly int $dpi) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--dpi', $this->dpi];
Expand Down
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/FooterCenterOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class FooterCenterOption implements ExtraOption
{
public function __construct(public readonly string $text) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--footer-center', $this->text];
}
}
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/FooterFontNameOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class FooterFontNameOption implements ExtraOption
{
public function __construct(public readonly string $fontName) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--footer-font-name', $this->fontName];
}
}
25 changes: 25 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/FooterFontSizeOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class FooterFontSizeOption implements ExtraOption
{
/**
* @param positive-int $size
*/
public function __construct(public readonly int $size) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--footer-font-size', $this->size];
}
}
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/FooterHtmlOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class FooterHtmlOption implements ExtraOption
{
public function __construct(public readonly string $uri) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--footer-html', $this->uri];
}
}
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/FooterLeftOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class FooterLeftOption implements ExtraOption
{
public function __construct(public readonly string $text) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--footer-left', $this->text];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class CollateOption implements ExtraOption
final class FooterLineOption implements ExtraOption
{
public function __construct() {}
public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--collate'];
return ['--footer-line'];
}
}
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/FooterRightOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class FooterRightOption implements ExtraOption
{
public function __construct(public readonly string $text) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--footer-right', $this->text];
}
}
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/FooterSpacingOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class FooterSpacingOption implements ExtraOption
{
public function __construct(public readonly int $spacing) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--footer-spacing', $this->spacing];
}
}
5 changes: 4 additions & 1 deletion src/Backend/WkHtmlToPdf/ExtraOption/GrayscaleOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

final class GrayscaleOption implements ExtraOption
{
public function __construct() {}
public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
Expand Down
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/HeaderCenterOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class HeaderCenterOption implements ExtraOption
{
public function __construct(public readonly string $text) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--header-center', $this->text];
}
}
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/HeaderFontNameOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class HeaderFontNameOption implements ExtraOption
{
public function __construct(public readonly string $fontName) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--header-font-name', $this->fontName];
}
}
25 changes: 25 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/HeaderFontSizeOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class HeaderFontSizeOption implements ExtraOption
{
/**
* @param positive-int $size
*/
public function __construct(public readonly int $size) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--header-font-size', $this->size];
}
}
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/HeaderHtmlOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class HeaderHtmlOption implements ExtraOption
{
public function __construct(public readonly string $uri) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--header-html', $this->uri];
}
}
22 changes: 22 additions & 0 deletions src/Backend/WkHtmlToPdf/ExtraOption/HeaderLeftOption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

final class HeaderLeftOption implements ExtraOption
{
public function __construct(public readonly string $text) {}

public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--header-left', $this->text];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@

use KNPLabs\Snappy\Backend\WkHtmlToPdf\ExtraOption;

class Outline implements ExtraOption
final class HeaderLineOption implements ExtraOption
{
public function isRepeatable(): bool
{
return false;
}

public function compile(): array
{
return ['--outline'];
return ['--header-line'];
}
}
}
Loading
Loading