diff --git a/src/Api/Utils/ApiClient.php b/src/Api/Utils/ApiClient.php index dcba3a7..627506a 100644 --- a/src/Api/Utils/ApiClient.php +++ b/src/Api/Utils/ApiClient.php @@ -112,19 +112,18 @@ protected function getNextSequence(string $objectType = self::INVOICE) : SevSequ protected function getPdf(string $path) { $response = $this->_get($path); - $file = $response['filename']; - file_put_contents($file, base64_decode($response['content'])); - - if (file_exists($file)) { - header('Content-Description: File Transfer'); - header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename="' . basename($file) . '"'); - header('Expires: 0'); - header('Cache-Control: must-revalidate'); - header('Pragma: public'); - header('Content-Length: ' . filesize($file)); - readfile($file); - exit(); - } + $content = base64_decode($response['content']); + $filename = $response['filename']; + + header('Content-Description: File Transfer'); + header('Content-Type: application/pdf'); + header('Content-Disposition: attachment; filename="' . basename($filename) . '"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . strlen($content)); + + echo $content; + exit(); } }