Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| TextField | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Interactive\Form; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfName; |
| 8 | use Phpdftk\Pdf\Core\PdfNumber; |
| 9 | use Phpdftk\Pdf\Core\PdfVersion; |
| 10 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 11 | |
| 12 | /** |
| 13 | * Text field (/FT /Tx). |
| 14 | */ |
| 15 | #[RequiresPdfVersion(PdfVersion::V1_2)] |
| 16 | class TextField extends Field |
| 17 | { |
| 18 | public ?int $maxLen = null; // /MaxLen |
| 19 | |
| 20 | public function __construct() |
| 21 | { |
| 22 | $this->ft = new PdfName('Tx'); |
| 23 | } |
| 24 | |
| 25 | public function toPdf(): string |
| 26 | { |
| 27 | $dict = $this->buildFieldDictionary(); |
| 28 | |
| 29 | if ($this->maxLen !== null) { |
| 30 | $dict->set('MaxLen', new PdfNumber($this->maxLen)); |
| 31 | } |
| 32 | |
| 33 | return $dict->toPdf(); |
| 34 | } |
| 35 | } |