Closed eusonlito closed 3 years ago
Hmm, can you give me a use case?
The temp files will not be deleted as long as you have a reference to your Pdf
variable somewhere in your code. So why is this useful?
For testing. I can execute the render one time, get the command with $pdf->getCommand()
and execute it in terminal multiple times with previously pregenerated HTML files.
That sounds like a very special case to me and I don't think we need an additional option for this.
If you want to keep the created temp files for HTML it should work if you create them outside of the library and pass them to addPage()
. Then you can also set whatever options you want there (and reuse them).
I have used a lot this feature on multiple proyects (edited vendor package manually).
Currently I have used with headers and footers rendering problem. Using a single option is a lot of more easy than write code, test and undo code.
My code is something similar to:
/**
* @return string
*/
public function contents(): string
{
return Pdf::fromHtml($this->html(), [
'tmpDelete' => false,
'margin-top' => '19',
'margin-bottom' => '10',
'header-html' => view('user.profile.pdf.header')->render(),
])->toString();
}
/**
* @return string
*/
public function html(): string
{
return view('user.profile.pdf.detail', [
'user' => $this->user,
])->render();
}
Anyway, thanks, I always can use my fork :)
Ok. I still think it's very specific to your project and I also showed a workaround.
Thanks für the suggestion anyway.
This new option
tmpDelete
allow to retain tmp HTML files after PDF is generated.