I've been playing around with Snappy to generate PDFs from a Laravel View. The PDF is an invoice and ideally I'd like to store it and then automatically email a copy to a client.
It seems like an image of my view is being generated and I can't copy/paste text from the PDF. The files can become large if my invoices are several pages - not ideal for storage or email.
Neither of these problems occur when I print the page to a PDF using the browser (I can't remember if I have some sort of plug-in installed), so I know it's possible to generate a different type of PDF.
Any suggestions? Is there some Snappy configuration that I'm missing? Do you guys have other package suggestions?
If size is a problen, have you considered zipping it? Zip and un-zipping is pretty standard. I send several monthly reports via email zipped. Sorry, not in laravel though.
I thought it went without saying, the user could just unzip at their end. But users, we all know. Have you looked at maybe a text format? Might be a lot smaller. Just attach a text file instead of pdf. Just a thought, but interesting problem.
@CodebyRay - Thanks! Yes, the dpi would help with the size but I still can't search and select text from the file (they way I can if I just print to pdf from my browser)
Will get back to this problem shortly and update when I come up with the right solution.
@harjovica - Thanks, but at first glance I'm not sure that either of those are what I'm looking for....I need to convert an HTML page to a non-image PDF, not build up a PDF form using PHP. Either way, I'll take a closer look.
@CodebyRay - I started trying to use it (before Snappy), but I couldn't get the dependencies sorted out. My server's PHP is @ 5.4 and there were some packages that dompdf required that I wasn't able to get.
A php update is not up to me at this point, but I'll certainly give it another try if we upgrade or if anyone can suggest a workaround.
Good to know that it'll work for my purpose. Thanks!
@36864 - Laravel 5.0. I remember playing around with different versions but a good idea to go back and take a closer look. Not sure I want to revert to Laravel 4.
@HAJROVICA - @hajrovica, can you share how you got php-pdftk to install in Laravel? I installed it using composer, and it shows up under vendors, but my controller is not recognizing it, saying "Class 'Vendor\mikehaertl\pdftk\Pdf' not found". I'm using Laravel 5.5 and have installed PDftk on my system as required. Not sure what I'm missing.
@hondaman900
Hi as i recall nothing specific was needed to install php-pdftk
Pulled it with composer
used it in standard way:
use mikehaertl\pdftk\Pdf;
can you share your code?
also do composer selfupdate
Check is your name space ok - i am not sure should it say Class 'Vendor\mikehaertl\pdftk\Pdf' not found or should it be Class 'mikehaertl\pdftk\Pdf' not found?