pdf = $pdf; } public function getStream(): StreamInterface { $resource = fopen('php://temp', 'r+'); if ($resource === false) { throw new RuntimeException("Could not open temp."); } fwrite($resource, $this->getString()); rewind($resource); return new Stream($resource); } public function getString(): string { return $this->pdf->output('', 'S'); } public function getLength(): int { return strlen($this->getString()); } }