I have downloaded and copied both binaries for both wkhtmltopdf and Xvfb in an appropriate directory, but when I select wkhtmltopdf as the PDF creation tool nothing happens: the page reloads and stays the same.

When I look at the Drupal logs it seems that there is a permissions issue, this is the message I get:
wkhtmltopdf: sh: myinstalldirectory/sites/all/modules/print/lib/wkhtmltopdf/wkhtmltopdf: Permission denied

Do you have any idea of which permissions I should grant in order to make it work?

Thanks in advanced

Comments

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

That seems to be a permission denied issued by the Linux shell.. Can you do 'ls -l' of the myinstalldirectory/sites/all/modules/print/lib/wkhtmltopdf directory, and tell me the permissions string (should be a mix of rwx).

It may be that the sh user doesn't have permissions to execute the file.. Maybe do a chmod to grant him execution permissions?

João

castawaybcn’s picture

wow, that was a quick answer!

it definitely is a linux box, but in a shared host. The only way to access it would be through ssh but I'm afraid this is not an option for now. I can however change the permissions through the cpanel interface. But I don't know what permissions I should be applying. I tried 0774 and got rid of the error message but still no pdf is generated, any suggestions?

ta

jcnventura’s picture

If you got rid of that error message, then you are now able to (maybe) execute it. If no PDF is generated, it means that an error occurred somewhere in the process.. I believe I try to catch any error message from the process and turn it into a Drupal log message. Do you have other messages in the log?

castawaybcn’s picture

nope, that's what puzzles me. I have absolutely no clue to what's happening.

jcnventura’s picture

Does the request terminate in an empty page? Does it go back to the original page? Or does it just keep waiting for the server to respond??

João

castawaybcn’s picture

it just goes back to the original page, from a user's point of view it looks as if you reloaded the page.

jcnventura’s picture

OK..

That means that the output of the wkhtmltopdf was empty. However, if there were any error messages, they should have been reported in the Drupal log..

So no logs and no PDF.. Absolutely nothing to know where the problem is :)

Without shell access it's impossible to ask you execute the binary directly or even to check the running process list.. Maybe I can recommend using TCPDF...

João

castawaybcn’s picture

I tried, but it does not seem to find neither my print_logo nor work well with the Brilliant Gallery Module... The first I could live with, but not the second (nothing gets printed at all)

Rustan’s picture

I have the exact same situation, running on a shared linux server, just updated print and wanted to try this new variant. I've configured print so that the pdf shall open in a new window, but in that window the page with the link reloads, and no pdf is shown. I used tcpdf fine with previous version, but have not installed it when updating print.

I have shell access, but have severe resritctions on it so far from an ideal test environment. Some programs that do work over the web do not work from the shell. I used what ought to be the correct Xvfb, but I do not have access to uname...

$ ls -l modules/print/lib/
total 10868
-rw-r--r-- 1 userX userX     191 Apr 28 00:53 README.txt
-rwxr-xr-x 1 userX userX 3979536 Dec  8 19:34 Xvfb
-rw-r--r-- 1 userX userX 7125592 May  5 12:09 wkhtmltopdf
$ ./Xvfb 
bash: ./Xvfb: /lib/ld-linux.so.1: bad ELF interpreter: No such file or directory

Anything I can try?

xurubo93’s picture

I managed to get wkhtmltopdf running on my webserver, but it was not only done by copying the static binaries into a folder. I installed a lot of packages which are prerequisites for this tool.

In your case I think the glibc-library is missing on your linux machine. This package provides the ld-linux library.

So i guess that using wkhtmltopdf is restricted to those people who have root access to the webservers.

jcnventura’s picture

@Rustan: The binary of Xvfb which you have in the site doesn't seem to be linked with the same libraries as the rest of your system.. I would guess that you have to upload a static version of Xvfb or re-compile Xvfb in your system. Maybe you can ask your shared host provider if they can install Xvfb for you in the system...

@xurubo93: Specifically the requirement for a running X server is a major annoyance. I would guess 99% of shared hosting users will not be able to get wkhtmltopdf running.

João

Rustan’s picture

Nope, no luck there, the host do not want to install xvfb. I will continue using tcpdf, so no problem for me. Just wanted to help with testing :)

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Two weeks without further info. Closing the issue.

ggamba’s picture

Hi Joao, I'm in the same situation of castawaybcn, no logs and no PDF, but I have shell access. I had to specify the font path for xvfb and had to manually create /etc/X11/xserver/SecurityPolicy. Maybe I did something wrong but I can't see the failing output...what should be the command to execute the binary directly?

Thanks and best
Gabriele

ggamba’s picture

Status: Closed (fixed) » Active
jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

The output should be in the Drupal error logs..

As to the direct command line: wkhtmltopdf --page-size [a4|letter] --orientation [portrait|landscape] --dpi 96 --footer-font-size 7 --footer-right '[page]' - -

ggamba’s picture

jcnventura, thank you for your reply!
Unfortunately, since I specified the font path with -fp there is no output in Drupal error logs.
I launched the following command:

"/var/www/drupal6.x/sites/all/modules/print/lib# ./wkhtmltopdf --page-size a4 --orientation portrait --dpi 96 --footer-font-size 7 --footer-right 'http://...' - -"

but nothing happened. A pdf should be generated in /var/www/drupal6.x/sites/all/modules/print/lib ? No pdf and no errors... any hint?

Thanks
Gabriele

jcnventura’s picture

Sorry, the command line can't be like what I specified as that will take input from standard input and output to standard output. Try to read wkhtmltopdf instructions and don't use the final '- -', as that's only useful inside the module.

As to the -fp, that only removes some errors/warnings that you had before.. So if there's no errors reported in the logs, it's because the processes are not producing any error. Which is strange, as you're not getting any PDF..

ggamba’s picture

I went back to DomPDF: I'll try again wkhtmltopdf when an Ubuntu package will be released.
I had a look at the Debian package (http://packages.debian.org/unstable/utils/wkhtmltopdf ) and once realized that I had to update tons of libraries, I decided to wait.

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No further info in 2 weeks. Closing the issue.

open social’s picture

Title: How to use wkhtmltopdf? Change file(s) permissions? » Empty output of wkhtmltopdf (reload error)
Priority: Normal » Critical
Status: Closed (fixed) » Needs work
StatusFileSize
new143.94 KB

We are running into the same issues.

First we followed the Handbook installing wkhtmltopdf. This went well. We performed the commando

commando: wkhtmltopdf http://www.goalgorilla.com/ goalgorilla.pdf
(result is attached, so a good start)

But the Module did not recognize wkhtmltopdf yet. So we performed step 2 and 3 from the Handbook (Place the wkhtmltopdf executable and Xvfb binary into the print module lib directory).

[root@server-dds1 lib]# pwd
/home/xxxxxx/domains/xxxxxx/public_html/devel/sites/all/modules/print/lib

[root@server-dds1 lib]# ls -l
total 4
-rw-r--r-- 1 XXXXXX XXXXXX 191 May 26 14:57 README.txt
lrwxrwxrwx 1 root     root      33 May 27 09:28 wkhtmltopdf -> /opt/wkhtmltopdf/wkhtmltopdf-i386
lrwxrwxrwx 1 root     root      13 May 27 09:33 Xvfb -> /usr/bin/Xvfb

Now the module recognises wkhtmltopdf. But we got the reload error mentioned in post #0 and in our Drupal access log:

wkhtmltopdf Xvfb: Couldn't open RGB_DB '/usr/share/X11/rgb' error opening security policy file /usr/lib64/xserver/SecurityPolicy

So we created /usr/lib64/xserver/SecurityPolicy and the RGB_DB is in rgb.txt and placed in the right directory.

The module still doesn't work. The only message in our log states:

wkhtmltopdf: Loading pages (1/5) [> ] 0% [======> ] 10% [=======> ] 13% [=======> ] 13% [=========> ] 15% [==========> ] 18% [============> ] 21% [============================================================] 100% Error: Failed loading page file:///tmp/wktemp-b18bbab1-1225-4d4a-960b-9d71dcd87368.html (sometimes it will work just to ignore this error with --ignore-load-errors) 

So on the console the app works and we have nothing in the errorlog of the domain. Is there more logging in Drupal we can check or does anybody has an idea to fix the issue? We really appreciate your time and efforts!

open social’s picture

StatusFileSize
new5.97 KB

Turns out it already worked. You need to DISABLE the 'Send to printer' functionality in the Web Page print tab of the module admin.

jcnventura’s picture

Status: Needs work » Closed (fixed)

Please don't re-open old issues.. Anyway the "Send to printer" problem with wkhtmltopdf has now been fixed.