Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| PostScriptXObject | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Graphics\XObject; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 8 | use Phpdftk\Pdf\Core\PdfName; |
| 9 | use Phpdftk\Pdf\Core\PdfReference; |
| 10 | use Phpdftk\Pdf\Core\PdfStream; |
| 11 | use Phpdftk\Pdf\Core\DeprecatedPdfFeature; |
| 12 | |
| 13 | /** |
| 14 | * PostScript XObject (/Subtype /PS). |
| 15 | * ISO 32000-2 section 8.8.2. Deprecated since PDF 1.7.1. |
| 16 | * The stream data contains the PostScript language code. |
| 17 | */ |
| 18 | #[DeprecatedPdfFeature(since: '1.7.1', removedIn: '2.0')] |
| 19 | class PostScriptXObject extends PdfStream |
| 20 | { |
| 21 | public const PDF_TYPE = 'XObject'; |
| 22 | public const PDF_SUBTYPE = 'PS'; |
| 23 | |
| 24 | public ?PdfReference $level1 = null; // /Level1 - Level 1 PostScript fallback stream |
| 25 | |
| 26 | public function __construct(string $data = '') |
| 27 | { |
| 28 | parent::__construct(new PdfDictionary(), $data); |
| 29 | } |
| 30 | |
| 31 | public function toPdf(): string |
| 32 | { |
| 33 | $this->dictionary->set('Type', new PdfName(self::PDF_TYPE)); |
| 34 | $this->dictionary->set('Subtype', new PdfName(self::PDF_SUBTYPE)); |
| 35 | |
| 36 | if ($this->level1 !== null) { |
| 37 | $this->dictionary->set('Level1', $this->level1); |
| 38 | } |
| 39 | |
| 40 | return parent::toPdf(); |
| 41 | } |
| 42 | } |