Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
88.89% |
8 / 9 |
|
66.67% |
2 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SubmitFormAction | |
88.89% |
8 / 9 |
|
66.67% |
2 / 3 |
5.03 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getActionType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
3.03 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Action; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\FileSpec\FileSpec; |
| 8 | use Phpdftk\Pdf\Core\PdfArray; |
| 9 | use Phpdftk\Pdf\Core\PdfNumber; |
| 10 | use Phpdftk\Pdf\Core\PdfReference; |
| 11 | use Phpdftk\Pdf\Core\PdfVersion; |
| 12 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 13 | |
| 14 | /** |
| 15 | * Submit-form action (/S /SubmitForm) — ISO 32000-2 §12.7.5.2. |
| 16 | * POSTs form field values to a URL or file. |
| 17 | */ |
| 18 | #[RequiresPdfVersion(PdfVersion::V1_2)] |
| 19 | class SubmitFormAction extends Action |
| 20 | { |
| 21 | public FileSpec|PdfReference $f; // /F URL / file spec |
| 22 | public ?PdfArray $fields = null; // /Fields |
| 23 | public int $flags = 0; // /Flags |
| 24 | |
| 25 | public function __construct(FileSpec|PdfReference $f) |
| 26 | { |
| 27 | $this->f = $f; |
| 28 | } |
| 29 | |
| 30 | public function getActionType(): string |
| 31 | { |
| 32 | return 'SubmitForm'; |
| 33 | } |
| 34 | |
| 35 | public function toPdf(): string |
| 36 | { |
| 37 | $dict = $this->baseDictionary(); |
| 38 | $dict->set('F', $this->f); |
| 39 | if ($this->fields !== null) { |
| 40 | $dict->set('Fields', $this->fields); |
| 41 | } |
| 42 | if ($this->flags !== 0) { |
| 43 | $dict->set('Flags', new PdfNumber($this->flags)); |
| 44 | } |
| 45 | return $dict->toPdf(); |
| 46 | } |
| 47 | } |