Reputation: 69
1) I renamed "wkhtmltopdf-i386" to "wkhtmltopdf" and uploaded "wkhtmltopdf" to my server in a folder named "/usr/local/bin"
2) I uploaded the php integration script, in the same folder, and named it "pdf_class.php" (https://github.com/aur1mas/Wkhtmltopdf/blob/master/Wkhtmltopdf.php)
I upload this two files to the "/home/kacmaz/domains/xxx.com/public_html/test_pdf/"
3) I uploaded a file that I named "test.php", in the same folder, containing :
<?php
include "pdf_class.php";
try
{
$wkhtmltopdf = new Wkhtmltopdf(array('path' =>'/home/kacmaz/domains/xxx.com/public_html/test_pdf'));
//$wkhtmltopdf = new Wkhtmltopdf(array('path' => APPLICATION_PATH . '/../public/uploads/'));
$wkhtmltopdf->setTitle("Title");
$wkhtmltopdf->setHtml("http://www.google.com");
$wkhtmltopdf->output(Wkhtmltopdf::MODE_DOWNLOAD, "myfile.pdf");
}
catch (Exception $e)
{
echo $e->getMessage();
}
?>
It creates files like "779753975.html" "749335291.html" to the "/home/kacmaz/domains/xxx.com/public_html/test_pdf/" ( files are 21 byte and it writes "http://www.google.com" inside the file )
But It give this error
WKHTMLTOPDF didn't return any data
And there is no pdf file, How Can I solve this problem ?
Upvotes: 1
Views: 2003
Reputation: 13402
I can't really duplicate the environment at the moment, but I would suggest trying to replace
$wkhtmltopdf->setHtml("http://www.google.com");
with
$wkhtmltopdf->setHtml("<h1>This Is A Test</h1><p>Ponies</p>");
And seeing what that produces. It sounds like some temp files are being generated and the setHtml writes it's contents to the temp files and the pdf is being generated based on those and that's why you get no data as it's not actually HTML contents.
Also, as always testing in the command line with similar content to see if it works there might eliminate some problems.
Upvotes: 1