Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| SigFieldLock | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Interactive\Form; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfArray; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfName; |
| 10 | use Phpdftk\Pdf\Core\PdfNumber; |
| 11 | use Phpdftk\Pdf\Core\PdfObject; |
| 12 | use Phpdftk\Pdf\Core\PdfVersion; |
| 13 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 14 | |
| 15 | /** |
| 16 | * Signature field lock dictionary — ISO 32000-2 §12.7.5.5, Table 233. |
| 17 | * |
| 18 | * Referenced from `SignatureField::$lock`. When the signature is |
| 19 | * applied, the viewer locks the listed fields (/Action + /Fields) and |
| 20 | * optionally applies `/P` (MDP permission level: 1=no changes, |
| 21 | * 2=form fill+sign, 3=everything above plus annotation edits). |
| 22 | */ |
| 23 | #[RequiresPdfVersion(PdfVersion::V1_5)] |
| 24 | class SigFieldLock extends PdfObject |
| 25 | { |
| 26 | public const PDF_TYPE = 'SigFieldLock'; |
| 27 | |
| 28 | public PdfName $action; // /Action All|Include|Exclude |
| 29 | public ?PdfArray $fields = null; // /Fields required unless Action=All |
| 30 | public ?int $p = null; // /P permission level |
| 31 | |
| 32 | public function __construct(string $action = 'All', ?PdfArray $fields = null) |
| 33 | { |
| 34 | $this->action = new PdfName($action); |
| 35 | $this->fields = $fields; |
| 36 | } |
| 37 | |
| 38 | public function toPdf(): string |
| 39 | { |
| 40 | $dict = new PdfDictionary(); |
| 41 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 42 | $dict->set('Action', $this->action); |
| 43 | if ($this->fields !== null) { |
| 44 | $dict->set('Fields', $this->fields); |
| 45 | } |
| 46 | if ($this->p !== null) { |
| 47 | $dict->set('P', new PdfNumber($this->p)); |
| 48 | } |
| 49 | return $dict->toPdf(); |
| 50 | } |
| 51 | } |