public function getStream($cache = false)
    {
        if (\is_int($this->stream)) {
            $length = PdfDictionary::get($this->value, 'Length');
            if ($this->parser !== null) {
                $length = PdfType::resolve($length, $this->parser);
            }

            if (!($length instanceof PdfNumeric) || $length->value === 0) {
                $this->reader->reset($this->stream, 100000);
                $buffer = $this->extractStream();
            } else {
                $this->reader->reset($this->stream, $length->value);
                $buffer = $this->reader->getBuffer(false);
                if ($this->parser !== null) {
                    $this->reader->reset($this->stream + strlen($buffer));
                    $this->parser->getTokenizer()->clearStack();
                    $token = $this->parser->readValue();
                    if ($token === false || !($token instanceof PdfToken) || $token->value !== 'endstream') {
                        $this->reader->reset($this->stream, 100000);
                        $buffer = $this->extractStream();
                        $this->reader->reset($this->stream + strlen($buffer));
                    }
                }
            }

            if ($cache === false) {
                return $buffer;
            }

            $this->stream = $buffer;
            $this->reader = null;
        }

        return $this->stream;
    }
public function getStream($cache = false)
    {
        if (\is_int($this->stream)) {
            $length = PdfDictionary::get($this->value, 'Length');
            if ($this->parser !== null) {
                $length = PdfType::resolve($length, $this->parser);
            }

            if (!($length instanceof PdfNumeric) || $length->value === 0) {
                $this->reader->reset($this->stream, 100000);
                $buffer = $this->extractStream();
            } else {
                $this->reader->reset($this->stream, $length->value);
                $buffer = $this->reader->getBuffer(false);
                if ($this->parser !== null) {
                    $this->reader->reset($this->stream + strlen($buffer));
                    $this->parser->getTokenizer()->clearStack();
                    $token = $this->parser->readValue();
                    if ($token === false || !($token instanceof PdfToken) || $token->value !== 'endstream') {
                        $this->reader->reset($this->stream, 100000);
                        $buffer = $this->extractStream();
                        $this->reader->reset($this->stream + strlen($buffer));
                    }
                }
            }

            if ($cache === false) {
                return $buffer;
            }

            $this->stream = $buffer;
            $this->reader = null;
        }

        return $this->stream;
    }
public function getStream ( $ cache = false ) { if ( \ is_int ( $ this -> stream ) ) { $ length = PdfDictionary :: get ( $ this -> value , 'Length' ) ; if ( $ this -> parser !== null ) { $ length = PdfType :: resolve ( $ length , $ this -> parser ) ; } if ( ! ( $ length instanceof PdfNumeric ) || $ length -> value === 0 ) { $ this -> reader -> reset ( $ this -> stream , 100000 ) ; $ buffer = $ this -> extractStream ( ) ; } else { $ this -> reader -> reset ( $ this -> stream , $ length -> value ) ; $ buffer = $ this -> reader -> getBuffer ( false ) ; if ( $ this -> parser !== null ) { $ this -> reader -> reset ( $ this -> stream + strlen ( $ buffer ) ) ; $ this -> parser -> getTokenizer ( ) -> clearStack ( ) ; $ token = $ this -> parser -> readValue ( ) ; if ( $ token === false || ! ( $ token instanceof PdfToken ) || $ token -> value !== 'endstream' ) { $ this -> reader -> reset ( $ this -> stream , 100000 ) ; $ buffer = $ this -> extractStream ( ) ; $ this -> reader -> reset ( $ this -> stream + strlen ( $ buffer ) ) ; } } } if ( $ cache === false ) { return $ buffer ; } $ this -> stream = $ buffer ; $ this -> reader = null ; } return $ this -> stream ; }
Get the stream data.

@param bool $cache Whether cache the stream data or not.
@return bool|string
@throws PdfTypeException
@throws CrossReferenceException
@throws PdfParserException
Get the stream data .