How to convert .txt file to .pdf on upload itself ?
Dear Friends,
I am looking a code solution in Laravel to convert a .txt file (for eg: a.txt) on server to a.pdf when the process of uploading itself.
Thanks
Anes
Good question. I have the same. It helps me in my work, I guess.
Use DomPDF:
https://github.com/barryvdh/laravel-dompdf
- accept the uploaded txt file
- get its contents and run through
nl2br() to create html <br> instead of newlines
- use the package's
loadHTML($contents) method to create a PDF from that text.
Please or to participate in this conversation.