Reputation: 31
I'm trying to generate a pdf using Snappy. I've already read the documentation at https://github.com/KnpLabs/snappy and try the code.
require_once '/KnpLabs/src/autoload.php';
use Knp\Snappy\Pdf;
$snappy = new Pdf('C:\Program Files (x86)\wkhtmltopdf');
// Display the resulting image in the browser
// by setting the Content-type header to jpg
$snappy = new Pdf('C:\Program Files (x86)\wkhtmltopdf');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="file.pdf"');
echo $snappy->getOutput('http://localhost/pdfTester/try.php');
when i click a link on try.php, there is a popup to open the pdf file and when i choose to open, a message appears.
Adobe Reader could not open 'file.pdf' because it is either not supported file type or because the file has been damaged
btw i just got one month-old exp with php and i already search for same topic but it looks like cannot help much. Any helps are appreciated.
Upvotes: 3
Views: 13582
Reputation: 13402
C:\Program Files (x86)\wkhtmltopdf
looks like it's pointing to a folder rather than the binary. If your wkhtmltopdf is installed into the folder C:\Program Files (x86)\wkhtmltopdf\
the binary would probably be C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe
, maby try pointing to the executable to see if that works? If that doesn't work, what happens when you try to run the command from command line? Does it work then?
wkhtmltopdf http://localhost/pdfTester/try.php test.pdf
Upvotes: 2