Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WKHTMLTOPDF didn't return any data #27

Closed
abolkog opened this issue Mar 14, 2013 · 10 comments
Closed

WKHTMLTOPDF didn't return any data #27

abolkog opened this issue Mar 14, 2013 · 10 comments

Comments

@abolkog
Copy link

abolkog commented Mar 14, 2013

I am getting this error when I set the engine to WkHtmlToPdf
Any ideas what did I do wrong ?

My configuration:
Configure::write('CakePdf', array(
'engine' => 'CakePdf.WkHtmlToPdf',
'margin' => array(
'bottom' => 15,
'left' => 50,
'right' => 30,
'top' => 45
),
'encoding'=>'UTF-8',
'download' => true
));

wkhtmltopdf version 0.9.9

Other engines are working fine but there are no images in the pdf file!

@abolkog
Copy link
Author

abolkog commented Mar 14, 2013

I am sorry , it appears the problem was with version 0.9.9
i removed it and installed 0.11.0 rc1 and it works great
Thank you so much for this plugin 👍

@abolkog abolkog closed this as completed Mar 14, 2013
@egpierro
Copy link

I am having the same issue, but I do have version 0.11.0 rc1 installed: "wkhtmltopdf-0.11.0-rc1 osx".

@ceeram
Copy link
Member

ceeram commented Mar 17, 2013

incorrect encoding also could cause this problem, cakepdf uses utf8 by default.
Besides that, i cant tell why wkhtml2pdf returns no content.

@egpierro
Copy link

Anything I can debug to get to the bottom of this issue?

@ceeram
Copy link
Member

ceeram commented Mar 17, 2013

CakePdf can only render if any content is being returned, its hard to tell why wkhtmltopdf is not returning any data.
You could perhaps try with very simple view and layout template, not images and external css.
also you can try wkhtmltopdf command from console, to check if it works when calling it directly.

@ceeram
Copy link
Member

ceeram commented Mar 17, 2013

You could drop by on irc #cakephp on freenode and ping me

@egpierro
Copy link

I did try using the console and it works fine. I also tried a simple HTML view, nothing fancy, just text, and still cannot get past that error message. :-/

On Mar 17, 2013, at 1:32 PM, ceeram notifications@github.com wrote:

CakePdf can only render if any content is being returned, its hard to tell why wkhtmltopdf is not returning any data.
You could perhaps try with very simple view and layout template, not images and external css.
also you can try wkhtmltopdf command from console, to check if it works when calling it directly.


Reply to this email directly or view it on GitHub.

@abolkog
Copy link
Author

abolkog commented Mar 18, 2013

I am not sure but if the console works fine maybe the problem is with your configuration
This is my configuration , its the default one actually nothing :

CakePlugin::load('CakePdf', array('bootstrap' => true, 'routes' => true));
Configure::write('CakePdf', array(
'engine' => 'CakePdf.WkHtmlToPdf',
'margin' => array(
'bottom' => 15,
'left' => 50,
'right' => 30,
'top' => 45
),
'encoding'=>'UTF-8',
'pageSize'=>'A4',
'download' => true
));

You can also try tracing the contents, in PLUGIN_HOMe/cakePdf/Pdf/Engine/WkThmlToPdfEngine.php, when I was googling about this i saw some post about the command ($command .= " --print-media-type";) might cause the problem, but I can't find now, sorry

@abolkog
Copy link
Author

abolkog commented Mar 18, 2013

Try re-installing wkhtml , maybe it will help.
This is how i installed it (working under ubuntu server)

wget https://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2
tar -vxf wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2
mv wkhtmltopdf-i386 wkhtmltopdf
chmod a+x wkhtmltopdf
sudo mv wkhtmltopdf /usr/bin

@Abuarif
Copy link

Abuarif commented Nov 13, 2014

Hi,

Alhamdulillah, I got wkhtmltopdf running on ubuntu after installing wkhtmltopdf as follows:

apt-get install wkhtmltopdf
apt-get install xvfb
echo 'xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf $*' > /usr/bin/wkhtmltopdf.sh
chmod a+x /usr/bin/wkhtmltopdf.sh
ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
wkhtmltopdf http://www.google.com output.pdf

[reference: http://fedir.github.io/web/blog/2013/09/25/install-wkhtmltopdf-on-ubuntu/]

and configure the bootstrap with

CakePlugin::load('CakePdf', array('bootstrap' => true, 'routes' => true));
Configure::write('CakePdf', array(
'binary' => '/usr/local/bin/wkhtmltopdf', // set the correct path here
'engine' => 'CakePdf.WkHtmlToPdf',
'margin' => array(
'bottom' => 15,
'left' => 15,
'right' => 15,
'top' => 20
),
'encoding'=>'UTF-8',
'pageSize'=>'A4',
'download' => false
));

[reference: https://stackoverflow.com/questions/23978338/cakepdf-plugin-wkhtmltopdf-binary-is-not-found/25472021#25472021]

I cheat the CSS using standard html style.

--enjoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants