Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow manual deletion of temporary files #53

Open
darkons opened this issue Sep 19, 2024 · 1 comment
Open

Allow manual deletion of temporary files #53

darkons opened this issue Sep 19, 2024 · 1 comment

Comments

@darkons
Copy link

darkons commented Sep 19, 2024

Currently temporary files are deleted via the __destruct method but this does not work when using PDFMerger through Laravel queues.

More info:
laravel/framework#18539

For this reason, it would be interesting to add a method that allows deleting temporary files manually for these use cases.

Something like this:

public function __destruct()
{
    $this->cleanup();
}

public function cleanup()
{
    $oFilesystem = $this->oFilesystem;
    $this->tmpFiles->each(function ($filePath) use ($oFilesystem) {
        $oFilesystem->delete($filePath);
    });
}

$pdfMerger = PDFMerger::init();
$pdfMerger->addPDF($path1, 'all');
$pdfMerger->addPDF($path2, 'all');
$pdfMerger->merge();
$pdfMerger->save('merged_result.pdf');
$pdfMerger->cleanup()

What do you think about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@darkons and others