laravel-snappy: Save function missing 'overwrite' argument

Hi, First, thanks for making this wrapper, it has been of great help to me. However, I have a small problem with the save function. I need it to be able to overwrite the file if it already exists on the filesystem and this is possible with Snappy by passing the $overwrite = True option to the ‘generate’ function. Unfortunately, this option is not included in your save function and so it throws an error if the file already exists. I have fixed it on my own system by amending your function to the following:

public function save($filename, $overwrite = false)
{

    if ($this->html)
    {
        $this->snappy->generateFromHtml($this->html, $filename, $this->options, $overwrite);
    }
    elseif ($this->file)
    {
        $this->snappy->generate($this->file, $filename, $this->options, $overwrite);
    }

    return $this;
}

I hope you will consider patching this for your next release as I think it is a handy function to have. Sorry if this was not the correct way to submit this, but Im not all that familiar with github and patching.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

I think $pdf->save($pdf, $overwrite = true); is not right. It should be $pdf->save($pdf, true);