Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 /** 3 * This file is part of FPDI 4 * 5 * @package setasign\Fpdi 6 * @copyright Copyright (c) 2019 Setasign - Jan Slabon (https://www.setasign.com) 7 * @license http://opensource.org/licenses/mit-license The MIT License 8 */ 9 10 namespace setasign\Fpdi\PdfParser\Type; 11 12 use setasign\Fpdi\PdfParser\StreamReader; 13 14 /** 15 * Class representing a hexadecimal encoded PDF string object 16 * 17 * @package setasign\Fpdi\PdfParser\Type 18 */ 19 class PdfHexString extends PdfType 20 { 21 /** 22 * Parses a hexadecimal string object from the stream reader. 23 * 24 * @param StreamReader $streamReader 25 * @return bool|self 26 */ 27 public static function parse(StreamReader $streamReader) 28 { 29 $bufferOffset = $streamReader->getOffset(); 30 31 /** 32 * @var string $buffer 33 * @var int $pos 34 */ 35 while (true) { 36 $buffer = $streamReader->getBuffer(false); 37 $pos = \strpos($buffer, '>', $bufferOffset); 38 if ($pos === false) { 39 if (!$streamReader->increaseLength()) { 40 return false; 41 } 42 continue; 43 } 44 45 break; 46 } 47 48 $result = \substr($buffer, $bufferOffset, $pos - $bufferOffset); 49 $streamReader->setOffset($pos + 1); 50 51 $v = new self; 52 $v->value = $result; 53 54 return $v; 55 } 56 57 /** 58 * Helper method to create an instance. 59 * 60 * @param string $string The hex encoded string. 61 * @return self 62 */ 63 public static function create($string) 64 { 65 $v = new self; 66 $v->value = $string; 67 68 return $v; 69 } 70 71 /** 72 * Ensures that the passed value is a PdfHexString instance. 73 * 74 * @param mixed $hexString 75 * @return self 76 * @throws PdfTypeException 77 */ 78 public static function ensure($hexString) 79 { 80 return PdfType::ensureType(self::class, $hexString, 'Hex string value expected.'); 81 } 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body