How to use snappy library with codeigniter.
i've installed and have it in my libraries folder . like
require_once dirname(FILE) . '/snappy/vendor/autoload.php'; use Knp\Snappy\Pdf;
class wkhtmltopdf extends Pdf { function __construct() { parent::__construct(); } }
2 ) then in contoller i've load it through function __construct()
$this->load->library('wkhtmltopdf');
in one of my controller i set binary like
$snappy = new wkhtmltopdf(""C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"");
and try it 4 )
echo $snappy->getOutput(array('http://www.google.com.pk'));
but the below error come.
but it thrown an error. Type: LogicException
Message: You must define a binary prior to conversion.
Filename: C:\xampp\htdocs\reporting-new-icn-huge-changes\application\libraries\snappy\vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php
Anybody have implemented wkhtmltopdf in codeignter through any method will be very helpful.
After download the library using Composer.
Add it in the Library folder and give the path for the autoload.php
Adjust the above path and outside of the Controller class
this is the Path to Binary file and in the Linux servers adjust it as given with the help of github.com/KnpLabs/snappy
#& inside the controller function
To get out put directly see this question. enter image description here
https://wkhtmltopdf.org/downloads.html the Exe file in windows and the same type of executable requires for Linux, Amazon etc. given on that page.
further requires this library which is wrapper used to set settings, output and other stuff etc. https://github.com/KnpLabs/snappy > this can be installed using git commands in vendor folder