Peejay Posted May 3, 2017 Share Posted May 3, 2017 Hi, I wan't to send a generated PDF with in an email attachment. To sent the email, I have to generate and save the PDF file. I' don't need it afterwards, zo I want to remove the generated PDF after some time. In the documentation i found there's a tempDir() method, but I can't get it to work. I use the dompdf library to generate a PDF This is my current test code: $dompdf = new Dompdf(); $dompdf->loadHtml('hello world'); // (Optional) Setup the paper size and orientation $dompdf->setPaper('A4', 'landscape'); // Render the HTML as PDF $dompdf->render(); $wireTempDir = files()->tempDir('test'); $output = $dompdf->output('test.pdf'); file_put_contents($wireTempDir, $output); Link to comment Share on other sites More sharing options...
Robin S Posted May 7, 2017 Share Posted May 7, 2017 On 3/05/2017 at 10:06 PM, Peejay said: file_put_contents($wireTempDir, $output); In your code $wireTempDir will only give the path to the temp directory, but file_put_contents() requires a filename too. So something like: file_put_contents($wireTempDir . '/temp.pdf', $output); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now