/usr/local/bin/wkhtmltopdf in snappy example is a linux binary location. Seems like you are using windows xampp. Download the wkhtmltopdf program from here https://wkhtmltopdf.org/downloads.html and update you path where you extracted the binary like so.
$snappy = new Pdf('C:path to where you extracted binary');
Also, make sure that the extracted path doesn’t required admin privileges to execute.
Please I am trying to use snappy for the first time to allow the user download PDF from my site. I previously used DomPDF but found it not suitable for the current situation. I first installed wkhtmltopdf, then I installed snappy using composer which installed it to c/users/computer-name/vendor (I am very new to composer). I copied the vendor folder to my project directory.
I added the code below;
require __DIR__ . '/vendor/autoload.php';
$snappy = new Pdf('/usr/local/bin/wkhtmltopdf');
header('Content-Disposition: attachment; filename="file.pdf"');
as shown here: https://github.com/knplabs/snappy
The PDF downloads but does not open. Chrome says “Failed to load PDF document”. When I open the PDF with notepad, I see the error;
Fatal error: Uncaught RuntimeException: The exit status code ‘1’ says something went wrong:
stderr: “The system cannot find the path specified.
command: /usr/local/bin/wkhtmltopdf –lowquality “https://www.google.com/" “C:UsersCHIDIE~1AppDataLocalTempknp_snappy5e42659b757116.59025588.pdf”. in C:xampphtdocscorporatecareertemplatesvendorknplabsknp-snappysrcKnpSnappyAbstractGenerator.php:381
Please help. What are my missing. I know I am doing something wrong.
Thanks for your answer. I did what you said and used $snappy = new Pdf(‘C:Program Fileswkhtmltopdfbinwkhtmltopdf’); but now it shows an error “C:Program’ is not recognized as an internal or external command”. Please do you know what else I could do? Google is not showing any solution as yet.
Thanks it works now. Installed again and changed the extracted path.