Skip to content

Allow manual deletion of temporary files #53

@darkons

Description

@darkons

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions