public static function parse(PdfDictionary $dictionary, StreamReader $reader, PdfParser $parser = null)
    {
        $v = new self;
        $v->value = $dictionary;
        $v->reader = $reader;
        $v->parser = $parser;

        $offset = $reader->getOffset();

        // Find the first "newline"
        while (($firstByte = $reader->getByte($offset)) !== false) {
            if ($firstByte !== "\n" && $firstByte !== "\r") {
                $offset++;
            } else {
                break;
            }
        }

        if (false === $firstByte) {
            throw new PdfTypeException(
                'Unable to parse stream data. No newline after the stream keyword found.',
                PdfTypeException::NO_NEWLINE_AFTER_STREAM_KEYWORD
            );
        }

        $sndByte = $reader->getByte($offset + 1);
        if ($firstByte === "\n" || $firstByte === "\r") {
            $offset++;
        }

        if ($sndByte === "\n" && $firstByte !== "\n") {
            $offset++;
        }

        $reader->setOffset($offset);
        // let's only save the byte-offset and read the stream only when needed
        $v->stream = $reader->getPosition() + $reader->getOffset();

        return $v;
    }