On his has shared a post showing how to create a ZIP file and stream the response in a -based application using the DOMPDF library and PHP’s ZipArchive functionality.

a file is easy and Rob Allen has you covered on that front to get you started. I needed to do this to create a zip file of PDF generated by Dompdf. It turns out, you can add to a ZipArchive object without actually creating the file if you can get the contents as a string.

The post includes the code to create the DOMPDF instance, load the HTML and render the result. From there the ZipArchive takes over and creates the archive from the PDF result. Finally the code takes the ZIP archive as input and pushes it out with a custom header to tell the browser to download it and streams back the raw ZIP contents.

Source link


Please enter your comment!
Please enter your name here