I updated to 6.1.11 and now when I click on the PDF icon, the page refreshes but not PDF is created.

I noticed in the status report that I has an error "The currently selected version of wkhtmltopdf () is not supported. Please update to a newer version." I was running 0.10.0_beta4 which was working before I updated the module. I uploaded 0.10.0_beta5 but I am still receiving the error.

As a precaution, I uninstall the Print module and reinstalled but the results are the same.

I downloaded wkhtmltopdf from http://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltopdf-0...

Comments

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

In which operating system are you? That warning was supposed to appear in wkhtmltopdf earlier than 0.9.6. I tested it in 0.10.0_beta4 and it worked for me.

João

2ndmile’s picture

Status: Postponed (maintainer needs more info) » Active

OS: Linux
Apache: 2.2.15
PHP: 5.2.9

jcnventura’s picture

Well, then it wasn't because of that...

João

2ndmile’s picture

For kicks, I commented out that check in the print_pdf.module file. Error gone in status update obviously but original problem persists, NO pdf created and page just refreshes.

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

The module should have reported the currently detected version in those parentheses.. The fact that it didn't is the problem.. In my case it

The module also denies any possibility of running an old version by returning the user to the original page instead of generating the PDF, and that's why it refreshes the page in your case.

Can you please run "wkhtmltopdf --version" and paste here the contents of the reply?

And if you're feeling a bit more adventurous, can you please replace the following line nearly at the end of print_pdf.module:
$out = preg_match('!.*?(\d+\.\d+\.\d+).*$!m', stream_get_contents($pipes[1]), $matches);
with
$out = preg_match('!.*?(\d+\.\d+\.\d+).*$!sm', stream_get_contents($pipes[1]), $matches);
and see if that fixes it?

João

2ndmile’s picture

Status: Postponed (maintainer needs more info) » Active

For further testing/troubleshooting, downgraded to 0.10.0_beta4 but problem persists, page refreshes no PDF created.

2ndmile’s picture

Status: Active » Fixed

Crap... forgot to change permissions for wkhtmltopdf to be executable. Fixed refresh problem and the error in the status report is no longer showing up.

It had been a while since my original install so I forgot about this step. You may want to update the INSTALL.txt to say that this file must be executable on the server... seems like an obvious thing, but obviously not.

I have another problem but I will open a new issue.

Anonymous’s picture

Status: Fixed » Active

I'm still experiencing this problem with OS X version of wkhtmltopdf. Output of --version:
Name:
wkhtmltopdf 0.10.0 beta4

Drupal 6.19
Print 6.x-1.11

I tried replacing the regular expression per instructions in #5, but no change. No version information is reported on the status report other than "unsupported version"

I've verified that wkhtmltopdf has executable permissions.

jcnventura’s picture

Status: Active » Fixed

This seems to be a OS X-only problem..

I don't have access to a Mac, so I have no idea how to fix the problem. Anyway, please create a new issue, as the original one is now fixed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

t14’s picture

Status: Closed (fixed) » Active

Hi have a similar problem on a windows platform

Any ideas how I can debug the problem.

Basically when I click the pdf link I get the page jus refreshes in a new window

I was using wkhtmltopdf version 0.9.9 and I have also tried version 0.10.0 beta 5 but no improvements

Thanks in advance for your help

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Do you get a warning in the status report?

t14’s picture

if you mean the drupal system log entries

Then no there is no warning

jcnventura’s picture

No, I mean the status report at admin/reports/status

t14’s picture

ah ok,

Yes it says:

"The currently selected version of wkhtmltopdf () is not supported. Please update to a newer version."

I am currenlty using version 0.10.0 beta5

What version do you recommend?

jcnventura’s picture

The module was unable to execute wkhtmltopdf.. I don't know why, but you can try to take a look at #911156: warning: proc_open() ... Create Process failed.

Matthew Davidson’s picture

Trying to get the version number from the command line:

$ ./wkhtmltopdf-i386 -V
./wkhtmltopdf-i386: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory

So apt-get install libxrender1 fixed the problem for me.

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No further info in more than two weeks. Closing the issue.

jayjaydluffy’s picture

Status: Closed (cannot reproduce) » Active

Hi! I've seen this thread and been trying to fix the same problem I have in my shared server using the methods by which you guys recommended to deal with the problem.

I have this specs in my shared host:
CentOS release 5.5 (Final)
x11 client lib is already installed => from technical support
PHP 5.2.14
Apache/2.2.16
x86_64 architecture

I'm still getting this error: "The currently selected version of wkhtmltopdf () is not supported. Please update to a newer version." even after I tried the fix above @ #5

I tried -i386 and -amd64
http://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltopdf-0...
http://code.google.com/p/wkhtmltopdf/downloads/detail?name=wkhtmltopdf-0...

but I still go the same error. I also tried commenting out some lines of print_pdf.module where it seeks about file version, so after saving, the error disappeared in Status Report page, but NO PDF is CREATED and the page just refreshes after creating book.

Can someone help me out here, again. Thank you so much!

cmrabet’s picture

Hi, getting the same issue here:

- Mac OS
- Last BETA version of wkhtmltopdf

When /site/printpdf/nid no PDF is generated, and the node pages just refreshes.

Thanks.

iuk2’s picture

I am having the same issue. My operating system is Linux.

When I use the following command line

sudo ln -s /opt/wkhtmltopdf

it generated a PDF page. But when I click PDF icon, nothing happens; it appears that page is just refreshed.

Thanks in advanced.

ice5nake’s picture

Version: 6.x-1.11 » 6.x-1.12

This issue appears to be caused by the _print_pdf_wkhtmltopdf function in the module. Because this code hits the drupal_goto because the $version variable is empty.

This code is pulled from print_pdf.pages.inc

	$version = _print_pdf_wkhtmltopdf_version();
	header('X-1337-ice5nake: Your wkhtmltopdf version is:' . $version);
	/*
	// 0.10.0 beta2 identifies itself as 0.9.9
  if (version_compare($version, '0.9.9', '>=')) {
    $print_pdf_wkhtmltopdf_options = '--disable-local-file-access '. $print_pdf_wkhtmltopdf_options;
  }
  elseif (version_compare($version, '0.9.6', '>=')) {
    $print_pdf_wkhtmltopdf_options = '--disallow-local-file-access '. $print_pdf_wkhtmltopdf_options;
  }
  else {
    drupal_goto($print['url']);
    exit;
	}

So I commented that code out and then I just hit a later drupal_goto because the $pdf variable is empty. So whether or not you get this error is probably dependent upon which version of wkhtmltopdf you are using. I've tried both versions on their site currently, 0.10.0_rc1 and 0.9.9

I also dumped the content of the $cmd variable to a HTTP header so I could see it.

/opt/wkhtmltopdf --page-size A4 --orientation portrait --dpi 96 --footer-font-size 7 --footer-right '[page]' - -

ice5nake’s picture

It checks the version in print_pdf.pages.inc too. I commented both out and it still doesn't work. Thinking I might have to try the dompdf route instead.

ice5nake’s picture

I am getting "wkhtmltopdf: sh: /usr/bin/wkhtmltopdf: Permission denied" in my Drupal log.

I ran

sudo -u apache wkhtmltopdf http://inordinatemind.com /var/www/html/sites/default/files/wkhtml-test.pdf

and it worked just fine. I am using wkhtmltopdf 0.10.0 rc1 and PHP 5.3

It failed the is_executable PHP function too though and I had to comment that out.

*****@*******:$ getfacl /usr/bin/wkhtmltopdf 
getfacl: Removing leading '/' from absolute path names
# file: usr/bin/wkhtmltopdf
# owner: apache
# group: apache
user::rwx
group::r-x
other::r-x

The permissions are set to allow.

ice5nake’s picture

ice5nake’s picture

In case anyone is following this thread. SELinux can block wkhtmltopdf from working through PHP even though it may be working at the command line level.

jayjaydluffy’s picture

I just have PDF printing working again when I changed hosting service! The former hosting service blocked some PHP functions that wkhtmltopdf is using, thus making the binary unexecutable and/or in some cases, not supported version!

I think that was proc_open() function that they blocked. They said it's for security reasons they restricted execution of that function. They tried to unblock that to us, but the more things messed up and PDF creation was still unattainable.

Maybe you could go on looking for other hosting services, if necessary.

drupalnesia’s picture

I have update the Documentation of http://drupal.org/node/306882 according to #7:
- IMPORTANT: make sure you give executable permission such as 755 to wkhtmltopdf file

@jcnventura: the incompatible version of wkhtmltopdf message may be wrong, I use wkhtmltopdf-0.9.9-static-amd64 but still error. I will check why not running well while my other server can run wkhtmltopdf-0.9.9-static-amd64.

#26: interested! need confirmation to include to Print module documentation
#27: I will check required php functions and will update the Documentation

drupalnesia’s picture

jcnventura’s picture

Status: Active » Fixed

@jayjaydluffy, @ice5nake: glad to know you fixed it.

@drupal-id.com: thanks for improving the documentation!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

charlie-s’s picture

I've tried without luck to get wkhtmltopdf working on a new server. It was working on the old system (CentOS) but we recently migrated to a VPS.net Ubuntu server and the problem began. The wkhtmltopdf binary in sites/all/modules/print/lib wasn't modified, and I verified that it is 755. Executing the program from terminal gave no response; as did "wkhtmltopdf -V" or "wkhtmltopdf --help". I verified I have X11 and QT4 installed. I also have Xvfb with a symlink pointing from ./lib to the binary in /usr/bin.

Nothing in the Drupal or system logs when I attempt to run the program manually or from node/x/pdf.

I deleted my wkhtmltopdf binaries and grabbed a new static binary from the Google Code repository (0.10.0) but I'm experiencing the same results.

Any ideas or suggestions? Thanks for any help.

charlie-s’s picture

I've tried 0.9.9 static and 0.10.0_rc2 in my /lib/ folder but still receive "The currently selected version of wkhtmltopdf () is not supported. Please update to a newer version." This error message needs to be fixed in the code, since it's apparently not doing any version checking.

jcnventura’s picture

It is checking the version perfectly.. If your wkhtmltopdf binary were able to get executed, you'd see the version between the parentheses.. The module runs wkhtmltopdf -V and tries to read the version number there..

charlie-s’s picture

It's executable but "wkhtmltopdf -V" returns a new line, nothing is outputted. I will switch to dompdf.

Zsuffa Dávid’s picture

I had the same issue, page reload no pdf generated and the error message 'sh: /wkhtmltopdf-i386 not found'

It was caused by

safe-mode = on
safe_mode_exec_dir = ""

I changed the safe_mode_exec_dir to point to "/var/www/..../modules/print/lib" and the pdf is downloading.

david

SchwebDesign’s picture

subscribing, having same issues here... followed instructions at faq http://drupal.org/node/190173#wkhtmltopdf_version : both the issue with the page just refreshing and the Unsupported version message.

my versions:
wkhtmltopdf-0.10.0_rc2-static-amd64
drupal 6.22
print 1.14
WHM 11.30.4 (build 6)
CENTOS 5.7 x86_64
Apache/2.2.19
PHP 5.2.17

Do i "need" to follow the instructions here? http://code.google.com/p/wkhtmltopdf/wiki/compilation

guerrilla’s picture

Version: 6.x-1.12 » 7.x-1.0-beta1
Status: Closed (fixed) » Active

Hey!

Try out this:

replace row:

$cmd = realpath($print_pdf_pdf_tool) . ' --version';

with this one:

$cmd = '"' . realpath($print_pdf_pdf_tool) . '"' . ' --version';

in function "_print_pdf_wkhtmltopdf_version" ("print_pdf.module" file)

Possible that you'll also need to copy dll's from installation dir to libraries dir (I had an error that libgcc_s_dw2-1.dll is missing and copied all of them).

This helped me. And now I had another error... But this is another story :)

guerrilla’s picture

Hey!

If that helped, you also need to replace row number 382 in print_pdf.pages.inc:

$cmd = realpath($print_pdf_pdf_tool) . " --page-size $print_pdf_paper_size --orientation $print_pdf_page_orientation --dpi $dpi $print_pdf_wkhtmltopdf_options - -";

with this one:

$cmd = '"' . realpath($print_pdf_pdf_tool) . '"' . " --page-size $print_pdf_paper_size --orientation $print_pdf_page_orientation --dpi $dpi $print_pdf_wkhtmltopdf_options - -";

I won! :) Worked!!!

jcnventura’s picture

Status: Active » Closed (fixed)

Ah, the joys of using Windows.. I've added the double quotes in those lines..

Anyone else, please don't reopen this thread.. Open a new one please.

anneeasterling’s picture

Issue summary: View changes

Leaving this tip here for future searchers.

Symlink from /usr/bin/wkhtmltopdf to folder in /sites/all/libraries/wkhtmltopdf may be needed. There may be other ways to do it, but that's the only thing that worked for us.