0

As far as I read wkhtmltopdf is using a patched version of Qt so that it can be executed WITHOUT using a graphical server such as Xorg, etc but when I run it in my OSX, it opens an application, it's visible in dock and when I press Command-Tab it's visible in list of applications shown, the icon of this app is a text "exec" in a black background. As soon as I focus this app it gets closed and wkhtmltopdf finishes its job but if I don't focus it, it doesn't finish its job at all. Any ideas what can I do? I want it to run in background and respond automatically, I can't sit behind the system and Command-Tab each time a request is sent.

Update: I tried it with an Ubuntu Server and it raises this error:

wkhtmltopdf: cannot connect to X server localhost:10.0

when I try to run wkhtmltopdf directly in command line. Isn't it against to whole purpose of patching Qt so that it doesn't need an X server?

Sassan
  • 2,187
  • 2
  • 24
  • 43

2 Answers2

0

It got solved after I faced the problem in Ubuntu, by searching the error raised in Ubuntu I could find this post wkhtmltopdf: cannot connect to X server which seems led me to install the package from sourceforge (both in OSX and Ubuntu) and it solved my problem (both in OSX and Ubuntu)

Community
  • 1
  • 1
Sassan
  • 2,187
  • 2
  • 24
  • 43
0

You must copy it into directory : /usr/local/bin, make sur it's executable and add symlink of wkhtmltopdf.sh like :

1- the command :

brew cask install wkhtmltopdf

2 - insert the binary in directory /usr/bin so the browser can't have permission to execute in this directory. You must copy the wkhtmltopdf.sh to directory /usr/local/bin cause the browser have permission in this directory like:

sudo cp /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf.sh

3 - After make sur the binary have permission of execution like :

sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh

4 - so now you can test, it's work like:

/usr/local/bin/wkhtmltopdf.sh http://www.google.com google.pdf

it make download the pdf in the current directory in your terminal

5 - Optional now you can add symlink in your directory /usr/local/bin like

ln -s /usr/local/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf

6 - copy to the /usr/bin/wkhtmltoimage into /usr/local/bin/wkhtmltoimage like:

sudo cp usr/local/wkhtmltoimage usr/local/bin/wkhtmltoimage

8- make sur this is executable too:

sudo chmod a+x /usr/local/bin/wkhtmltoimage

I Hope it's help you

rapaelec
  • 1,238
  • 12
  • 10