spatie / laravel-pdf

Create PDF files in Laravel apps
https://spatie.be/docs/laravel-pdf
MIT License
728 stars 56 forks source link

Fix inconsistent behavior in save() method when using vs not using a disk #196

Open aalyusuf opened 1 week ago

aalyusuf commented 1 week ago

Currently, the save() function behaves slightly differently when using a disk versus not using one. This PR resolves the inconsistency by creating a temporary file during saving.

Example of the issue:

Pdf::view('invoice')->save('invoice.png'); // Saves a PNG file

Pdf::view('invoice')->disk('s3')->save('invoice.png'); // Saves a PDF file

Using $fileName instead of $path directly to avoid any errors when saving to a full path.

freekmurze commented 1 week ago

Could you add a test to prove that the changes work?

aalyusuf commented 1 week ago

@freekmurze Added :thumbsup: