Problems running wkhtmltopdf in php exec version 12

1,972 views
Skip to first unread message

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 13, 2014, 5:21:23 PM4/13/14
to wkhtmltop...@googlegroups.com
I'm working with version 12 in the shell runs well "./wkcentos564/bin/wkhtmltopdf - footer-html boletin_footer.html prueba1.html prueba.pdf" but in php
<?
$ cmd = "./wkcentos564/bin/wkhtmltopdf - footer-html boletin_footer.html prueba1.html prueba.pdf";
$ t = exec ($ cmd);
>

I do not run.
What do I need?
What am I doing wrong?

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 13, 2014, 5:56:18 PM4/13/14
to wkhtmltop...@googlegroups.com
I've also changed the routes so probabado
<?
$ cmd = "/ home1/yoice/public_html/informes_yes/wkcentos564/bin/wkhtmltopdf - footer-html boletin_footer.html prueba1.html / home1/yoice/public_html/informes_yes/prueba.pdf";
$ t = exec ($ cmd);
>
But nothing does not work

Chris Tate-Davies

unread,
Apr 14, 2014, 2:52:23 AM4/14/14
to wkhtmltop...@googlegroups.com, wkhtmltop...@googlegroups.com
I'm guessing you're using centos?

Have you got selinux enabled?
--
===================================================
You received this message because you are subscribed to the "wkhtmltopdf General" group.
To post to this group, send email to wkhtmltop...@googlegroups.com
To unsubscribe from this group, send email to wkhtmltopdf-gen...@googlegroups.com
 
For more options, visit this group at
http://groups.google.com/group/wkhtmltopdf-general?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "wkhtmltopdf General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wkhtmltopdf-gen...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Chris Tate-Davies

unread,
Apr 14, 2014, 5:43:35 AM4/14/14
to wkhtmltop...@googlegroups.com
I think what you need to ensure is that you allow SELinux to allow Apache to spawn processes:

sudo setsebool httpd_execmem on

HTH

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 7:25:55 AM4/14/14
to wkhtmltop...@googlegroups.com
Yeah, I'm actually using centos, I have my sites hosted on hostgator.com. But not as sure that SELinux is enabled. By entering sudo setsebool httpd_execmem on the shell I get the "sudo answer:. Effective uid is not 0, sudo is installed setuid root because I do not get much use linux because my tests were conducted in windows but the hostgator server is linux centos. thank you in advance for your help.

Currently he was working with wkhtmltopdf-amd64 but that version was not installed and that has worked very well for me in php exec. But I tried to update it for version 12 and will not run with me from php excel but if the shell desdel


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

Chris Tate-Davies

unread,
Apr 14, 2014, 7:57:47 AM4/14/14
to wkhtmltop...@googlegroups.com
Perhaps asking the hostgator support would be your best option here.

If it works in a terminal but doesn't work in a PHP script, it must be either Apache permissions or path to the WKHTMLTOPDF binaries? Or even the input HTML files...


--

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 8:14:14 AM4/14/14
to wkhtmltop...@googlegroups.com
But because I download older versions of http://code.google.com/p/wkhtmltopdf/downloads/list?can=1 if I work? with the same input file to version 11 works but try the version 12 does not work me. I can note is that the size of the version 12 is much higher than 11., and if it is not making it precompiled version 12. they do


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 8:16:29 AM4/14/14
to wkhtmltop...@googlegroups.com
when I do with the downloaded version 11 http://code.google.com/p/wkhtmltopdf/downloads/list?can=1 works perfectly on php, but changing the version 12 downloaded directly from wkhtmltopdf.org not me operates. and routes are fine.


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

Chris Tate-Davies

unread,
Apr 14, 2014, 8:23:22 AM4/14/14
to wkhtmltop...@googlegroups.com
Oh sorry, I thought it was working in terminal but just not in PHP

In that case, are you sure you downloaded the correct binary for your linux distro/arch?


--

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 8:44:25 AM4/14/14
to wkhtmltop...@googlegroups.com
So. in hostgator cpanel only says my OS is centos linux and was told that is 64 bit. Then I downloaded and tried downloading wkhtmltopdf version 12 64-bit Linux
and also
Linux (CentOS 5) 64-bit directly from the download link wkhtmltopdf.org. clearly says that there is precompiled. then when I run it in the terminal I work. but when I run it from php with exec me does not work. But this pass me with version 12. If I use version 11 if I work well in php.


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 10:20:36 AM4/14/14
to wkhtmltop...@googlegroups.com
???????????  ? ? ? ? ?

El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

Chris Tate-Davies

unread,
Apr 14, 2014, 10:32:27 AM4/14/14
to wkhtmltop...@googlegroups.com
So what are you saying? It works from PHP with version 0.11 but not 0.12


--

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 11:08:33 AM4/14/14
to wkhtmltop...@googlegroups.com
Exactly, works in php to version 11 release of http://code.google.com/p/wkhtmltopdf/downloads/list?can=1 but when with the release of version 12 http://wkhtmltopdf.org/ downloads.html not work in php.
Will have to do with what was version 12 are pre-compiled?


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 11:17:13 AM4/14/14
to wkhtmltop...@googlegroups.com
I need the version 12 since this fixes the thead and tfoot because in the 11th down this property does not work


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 11:25:34 AM4/14/14
to wkhtmltop...@googlegroups.com
???? ???? ??? ???? Estoy desesperado con este inconveniente


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 11:26:44 AM4/14/14
to wkhtmltop...@googlegroups.com
???? ???? ??? ???? I am desperate with this problem


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

Chris Tate-Davies

unread,
Apr 14, 2014, 11:38:44 AM4/14/14
to wkhtmltop...@googlegroups.com
Does version 12 work in your terminal?

If so, it must be within your PHP setup. Have you tried moving the binary to the same folder as the script and changing the relative paths, to test if it works?

Do you get any errors? Change the exec line to include the output:

$t = exec($cmd, $output);

Can you give us whats in :

var_dump($output);


--

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 11:43:40 AM4/14/14
to wkhtmltop...@googlegroups.com
Already did, the answer I get is this
  array (0) {}


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 11:47:52 AM4/14/14
to wkhtmltop...@googlegroups.com
Tambien he movido el binario a la misma ruta base, he probado de todas las maneras, pero nada, no se que hacer, lo unico que encuentro esque el que descargo de wkhtmltopdf.org es pre-compilado y es un archivo mas grande de los que encuentro en la pagina de http://code.google.com/p/wkhtmltopdf/downloads/list?can=1


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 11:50:27 AM4/14/14
to wkhtmltop...@googlegroups.com
I just confirmed that the OS hostgator I get is 64 bit centos 06


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 11:55:48 AM4/14/14
to wkhtmltop...@googlegroups.com
I have also moved the binary to the same base path, I tried in every way, but nothing, not to do, the only thing I find esque which release of wkhtmltopdf.org is pre-compiled and is a larger file of I find in the page http://code.google.com/p/wkhtmltopdf/downloads/list?can=1

The OS is centOS 06 64 bit


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

Chris Tate-Davies

unread,
Apr 14, 2014, 11:57:06 AM4/14/14
to wkhtmltop...@googlegroups.com
What if you run:

$result = exec("wkhtmltopdf --version", $output);
var_dump($output);

And try the absolute paths?

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 12:05:16 PM4/14/14
to wkhtmltop...@googlegroups.com
It is well for my case
$ result = exec ("./wkcentos5/bin/wkhtmltopdf - 0.12.0", $ output);
var_dump ($ output);
     exit ();
and gave me the following response
array (12) {[0] => string (0) "" [1] => string (0) "" [2] => string (0) "" [3] => string (0) "" [4] => string (0) "" [5] => string (0) "" [6] => string (0) "" [7] => string (0) "" [8] => string (0) "" [9] => string (0) "" [10] => string (0) "" [11] => string (0) ""}


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

Chris Tate-Davies

unread,
Apr 14, 2014, 12:13:11 PM4/14/14
to wkhtmltop...@googlegroups.com
No, you misunderstand me.

Don't put the actual version in, use the exact syntax:

<?php
$c = exec("wkhtmltopdf --version", $output);
var_dump($output);

The result should be something like this: http://pastebin.com/5kdix3se




--

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 12:22:08 PM4/14/14
to wkhtmltop...@googlegroups.com
ok, I went this
array (19) {[0] => string (5) "Name:" [1] => string (61) "wkhtmltopdf 0.12.1-b8882c825e8cafd923d5ba93704fdc6abea8bda3" [2] => string (0) "" [3] = > string (8) "License" [4] => string (55) "Copyright (C) 2010 wkhtmltopdf / wkhtmltoimage Authors." [5] => string (0) "" [6] => string (0) "" [7] => string (0) "" [8] => string (71) "License LGPLv3 +: GNU Lesser General Public . License version 3 or later "[9] => string (77)" This is free software:. you are free to "[10] => string (78)" change and redistribute it There is NO WARRANTY, to the Extent permitted by "[11] => string (6)" law. "[12] => string (0) "" [13] => string (8) "Authors:" [14] => string (78) "Written by Jan Habermann, Christian Sciberras and Jakob Truelsen Patches by" [15. ] => string (79) "Mehdi Abbad, Lyes Amazouz, Pascal Bach, Emmanuel Bouthenot, Benoit Garret and" [16] => string (14) "Mário Silva." [17] => string (0) "" [18] => string (42) "Compiled against wkhtmltopdf patched qt." }


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:

Chris Tate-Davies

unread,
Apr 14, 2014, 12:29:05 PM4/14/14
to wkhtmltop...@googlegroups.com
Okay, so that proves that wkhtmltopdf is working fine from PHP - you must be passing some invalid parameters or using the incorrect path.

I've looked back at your original syntax and it all looks wrong. It might be the formatting on the email, so please copy and paste the PHP code block into a new pastebin and give us the link for that.


--

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 12:38:09 PM4/14/14
to wkhtmltop...@googlegroups.com
This is my code
<?
$ Result = exec ("./wkhtmltopdf-amd64 prueba1.html prueba.pdf", $ output);
var_dump ($ output);
   
exit ();
>
wkhtmltopdf-amd64 binary if the version 11 working correctly but if version 12 will not work.

Even if I just do
<?
$ Result = exec ("./wkhtmltopdf-amd64 - version", $ output);
var_dump ($ output);
   
exit ();
>
Gives the result that I showed you, or should work but it does not generate the pdf with vesion 12

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 12:57:14 PM4/14/14
to wkhtmltop...@googlegroups.com
Comparing array
I work version is wkhtmltopdf 0.9.6
The works that I do is wkhtmltopdf 0.12.1 - b8882c825e8cafd923d5ba93704fdc6abea8bda3

This is the comparison between the one and the other

array ( 16) {
[0 ] = > string ( 5) " Name:"
[ 1] = > string ( 19) " wkhtmltopdf 0.9.6 "
[ 2] = > string ( 0) " "
[ 3] = > string (8 ) "License "
[ 4] = > string (46 ) "Copyright ( C ) 2008,2009 wkhtmltopdf Authors. "
[5 ] = > string ( 0) " "
[ 6] = > string ( 0) " "
[ 7] = > string ( 0) " "
[ 8] = > string (80 ) "License GPLv3 + : GNU GPL version 3 or later . "
[ 9] = > string (80 ) "This is free software : . You are free to change and redistribute it There is NO"
[ 10] = > string (43) " WARRANTY , to the Extent permitted by law . "
[ 11] = > string ( 0) " "
[ 12] = > string (8 ) "Authors "
[ 13] = > string (79 ) " Written by Jakob Truelsen . Patches by Mário Silva, Benoit Garret and Emmanuel "
[ 14] = > string ( 12) " Bouthenot . "
[ 15] = > string ( 0) ""}

array ( 19) {
[0 ] = > string ( 5) " Name:"
[ 1] = > string (61) " wkhtmltopdf 0.12.1 - b8882c825e8cafd923d5ba93704fdc6abea8bda3 "
[ 2] = > string ( 0) " "
[ 3] = > string (8 ) "License "
[ 4] = > string (55 ) "Copyright ( C ) 2010 wkhtmltopdf / wkhtmltoimage Authors. "
[5 ] = > string ( 0) " "
[ 6] = > string ( 0) " "
[ 7] = > string ( 0) " "
[ 8] = > string (71 ) " LGPLv3 + License : GNU Lesser General Public License version 3 or later "
[ 9] = > string (77 ) . " This is free software : you are free to"
[ 10] = > string (78 ) "change and redistribute it . There is NO WARRANTY , to the Extent permitted by"
[ 11] = > string (6 ) "law . "
[ 12] = > string ( 0) " "
[ 13] = > string (8 ) "Authors "
[ 14] = > string (78) " Written by Jan Habermann , Christian Sciberras and Jakob Truelsen . Patches by"
[ 15] = > string (79 ) " Mehdi Abbad , Lyes Amazouz , Pascal Bach, Emmanuel Bouthenot , and Benoit Garret "
[ 16] = > string ( 14) " Mário Silva. "
[17 ] = > string ( 0) " "
[18 ] = > string ( 42 ) " Compiled against wkhtmltopdf patched qt . " }


YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 1:30:41 PM4/14/14
to wkhtmltop...@googlegroups.com
??  ??? ??  help ???

Chris Tate-Davies

unread,
Apr 14, 2014, 2:29:55 PM4/14/14
to wkhtmltop...@googlegroups.com, wkhtmltop...@googlegroups.com
I'm afraid I don't know if I can help you any more. I've run out of ideas of what it could be. Doesn't make any sense. 

Sorry
--

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 2:59:24 PM4/14/14
to wkhtmltop...@googlegroups.com

OK THANKS. VERE I CAN DO MY PART, IF SOMETHING HAPPENS THEN YOU APPRECIATE YOU

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 4:00:21 PM4/14/14
to wkhtmltop...@googlegroups.com
This is the process conducted to upgrade to wkhtmltopdf 0.12.0. I put it here to see if any light comes out and I can help.
1. Downloaded the latest version
# wget http://sourceforge.net/projects/wkhtmltopdf/files/0.12.0/wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz/
Two. I extract the package
# Tar-linux-jxvf wkhtmltox amd64_0.12.0-03c001d.tar.xz
Three. Working with the pre-compiled / bin / wkhtmltopdf folder I've extracted, which is what is not working for me this version 0.12.0

What do I need?
Will need some process to install linux here.?

Again thank you very much and sorry for the inconvenience both.

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 8:57:52 PM4/14/14
to wkhtmltop...@googlegroups.com
???

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 14, 2014, 9:35:24 PM4/14/14
to wkhtmltop...@googlegroups.com
This is the response I get
array (2) {[0] => string (19) "Loading pages (1/6)" [1] => string (198) "[>] 0% [===>] 5% [=== ===>] 10% "}

Andrea Failli

unread,
Apr 15, 2014, 2:11:39 AM4/15/14
to wkhtmltop...@googlegroups.com
Hi,
maybe you can try to check the stderr output.
Change your $cmd in this way, and make sure you are using full paths.

<? 
$ cmd = "./wkcentos564/bin/wkhtmltopdf - footer-html boletin_footer.html prueba1.html prueba.pdf 2>&1"; 
$ t = exec ($ cmd,$ output); 
var_dump ($ output); 

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 15, 2014, 10:29:02 AM4/15/14
to wkhtmltop...@googlegroups.com
Thanks for your help. this is the answer
array (2) {[0] => string (19) "Loading pages (1/6)" [1] => string (132) "[>] 0% [======>] 10%" }

Only less than 10%, and not to do with that.

YOICE MANUEL MARQUEZ MONROY

unread,
Apr 15, 2014, 11:04:08 AM4/15/14
to wkhtmltop...@googlegroups.com
I tried with absolute paths and I do not generate the pdf
$ cmd = "/ home1/yoice/public_html/informes_yes/wkhtmltopdf-12amd64 http://eduktic.com/informes_yes/prueba1.html / home1/yoice/public_html/informes_yes/prueba.pdf 2> & 1";
$ t = exec ($ cmd, $ output);
var_dump ($ output);

DreamColo Colocation

unread,
Feb 18, 2015, 5:48:48 AM2/18/15
to wkhtmltop...@googlegroups.com
Hi,

Have you tried adding an option '--disable-javascript' into your 'wkhtmltopdf'? 

Hope this help,
Tukkae

张春辉

unread,
May 29, 2015, 11:36:45 PM5/29/15
to wkhtmltop...@googlegroups.com
Hi Chris,

I have same problem! But when I executed the command into PHP, I got bellow message: 
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
array(2) { [0]=> string(27) "which: no xauth in ((null))" [1]=> string(40) "xvfb-run: error: xauth command not found" }


My PHP code as bellow:
-----------------------------------
<?php
$var = array();
$res = 0;

$cmd    = '/usr/bin/xvfb-run --server-args="-screen 0, 1920x1080x24" /usr/local/bin/wkhtmltopdf http://www.google.com /tmp/google.pdf  2>&1';

/*
$result = exec("wkhtmltopdf --version", $var);
var_dump($var);
die();
*/

exec($cmd, $var, $res);
echo $cmd.'<br />';
var_dump ($var);
?>



And my wkhtmltopdf --version is 0.12.2.1, and my OS is CentOS release 6.6, And I executed the command on Terminal successful but PHP not!


Do you know how to resolved the issue: xvfb-run: error: xauth command not found



Thanks in advance,
-Chunhui


Chris Tate-Davies於 2014年4月14日星期一 UTC+8下午2時52分23秒寫道:
I'm guessing you're using centos?

Have you got selinux enabled?


On 13 Apr 2014, at 22:56, YOICE MANUEL MARQUEZ MONROY <yoice...@gmail.com> wrote:

I've also changed the routes so probabado
<?
$ cmd = "/ home1/yoice/public_html/informes_yes/wkcentos564/bin/wkhtmltopdf - footer-html boletin_footer.html prueba1.html / home1/yoice/public_html/informes_yes/prueba.pdf";
$ t = exec ($ cmd);
>
But nothing does not work


El domingo, 13 de abril de 2014 16:21:23 UTC-5, YOICE MANUEL MARQUEZ MONROY escribió:
I'm working with version 12 in the shell runs well "./wkcentos564/bin/wkhtmltopdf - footer-html boletin_footer.html prueba1.html prueba.pdf" but in php
<?
$ cmd = "./wkcentos564/bin/wkhtmltopdf - footer-html boletin_footer.html prueba1.html prueba.pdf";
$ t = exec ($ cmd);
>

I do not run.
What do I need?
What am I doing wrong?

--
===================================================
You received this message because you are subscribed to the "wkhtmltopdf General" group.
To post to this group, send email to wkhtmltop...@googlegroups.com
To unsubscribe from this group, send email to wkhtmltopdf-general+unsub...@googlegroups.com

 
For more options, visit this group at
http://groups.google.com/group/wkhtmltopdf-general?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "wkhtmltopdf General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wkhtmltopdf-general+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages