I'm on a shared host and wkhtmltopdf didn't work for me before. However, during the upgrade to 6.x-1.9, I gave it a try again, and it worked.

Not sure if it's related to the fact that, the latest build no longer requires a running XServer.

(Linux) No longer requires an XServer to be running (however the X11 client libs must be installed)>

Quoted from http://code.google.com/p/wkhtmltopdf/

I used the pre-built static binary and it successfully generated PDF files, which was previously not possible.

Compared to TCPDF, wkhtmltopdf generates the PDF with proper picture scaling, and the size is much smaller (200KB vs >1MB). However, the text in wkhtmltopdf-generated files, at least in my case, cannot be searched, copied nor pasted. They just become all square boxes. That's not the case with TCPDF.

Enclosed is an example PDF generated by wkhtmltopdf, the TCPDF-generated one of the same page is too large to be uploaded here, so I've put it at http://ifile.it/rg7fjm9/ByFai.com_-_The_Grass_-_2008-09-14%20-%20tcpdf.pdf

No idea about the resource usage, and if there will be other issues down the road, at this moment.

Any idea to resolve the text issues in wkhtmltopdf...?

Cheers.

Comments

loyukfai’s picture

Looks like the text issue is being followed at http://code.google.com/p/wkhtmltopdf/issues/detail?id=67

jcnventura’s picture

Status: Active » Closed (won't fix)

Thanks for letting me know about the problem. As you've seen it's a problem with wkhtmltopdf itself, so there's nothing I can do about it.

loyukfai’s picture

Welcome. And maybe you could update the wordings on the main project page as well (that it may now work even on a shared host).

jcnventura’s picture

I for one, still can't get it to work on my shared host :( So, I won't be removing those words from the project pag

But that's because the OS is Debian 4.0 based and I can't compile there.. According to http://code.google.com/p/wkhtmltopdf/issues/detail?id=32, they will make a glibc 2.3 binary for the next release, but I will have to wait for it..

drupalnesia’s picture

@jcnventura:

wkhtmltopdf now: Running without an X11 server. Not sure since which version, look like 0.9.9

I have tested it on 5 share hostings with WHM/CPanel on CentOS 5.5 64 bit.
NB: (Linux) No longer requires an XServer to be running (however the X11 client libs must be installed)

ukrdrupal’s picture

Status: Closed (won't fix) » Active

I have a Drupal site with the print module installed (on a shared cPanel hosting environment, apparently that has CentOS 4) and I am trying to get the wkhtmltopdf to work. I am not able to get it to work because - as I have determined - libX11 is not installed/available.

On a dedicated server I run, I have the proper libX11 installed and the wkhtmltopdf works with the print module for a Drupal site of mine. I really love how the wkhtmltopdf generates PDFs and want to get it to work on my cPanel hosting environment.

I use the most recent static version of wkhtmltopdf.

...Has anyone figured out a way to get all of the needed .so files (for their distribution / in this case, CentOS 4), make them available maybe in a library folder within the Drupal site and get the wkhtmltopdf to recognize the lib files there, for use? Does anyone know if the print module could be modified to handle this?

I have done quite a bit of searching on the web for many hours and many days, but I cannot find a suitable solution. I do see where someone made a shell script wrapper and obtained all of the needed .so files and got the wkhtmltopdf to output PDFs. So, it does seem possible, but I guess the print module and/or Drupal would need to be configured to handle this?

Please, if anyone has figured out a way to get this all running on cPanel shared hosting, let us know! I love wkhtmltopdf! IT IS WORTH THE EFFORT TO GET THIS TO WORK!!!

Here's the link on a solution offered (not in conjunction with Drupal, yet!):

http://stackoverflow.com/questions/2273534/how-to-install-wkhtmltopdf-on...

ukrdrupal’s picture

I have posted a unique question of my own, over on StackOverflow.com, more pertaining to the issue at hand. So, I am hoping someone will respond there, with a good answer, but also there may be someone here on the forums that has an answer and can post here on Drupal.org and over on StackOverflow.com. Here's the post:

http://stackoverflow.com/questions/3763417/how-do-i-get-wkhtmltopdf-runn...

drupalnesia’s picture

Look at my post on #5:

NB: (Linux) No longer requires an XServer to be running (however the X11 client libs must be installed)

The point is X11 clients libs is required.

ukrdrupal’s picture

@drupal-id.com, that was already understood and evidenced in my posts. The point is, that on cPanel shared hosting, the hosting company doesn't want to install the x11 libs. So, this is why people try to come up with solutions, like jockie did on StackOverflow.com, with the shell wrapper and the .so libs. You're reply really didn't help at all. Does anyone have a work around they can offer or has anyone implemented a shell wrapper with a Drupal installation?

jcnventura’s picture

Hi,

Just one comments before this gets out of hand. The print module already provides all the support for wkhtmltopdf that it needs. Using this wrapper is clearly something that the user will need to do for themselves, if they need it. I certainly don't want to be in charge of maintaining such a solution.

The module will look for something whose name starts with wkthtmltopdf in the sites/all/libraries directory or in the module directory. If your wrapper is called wkthtmltopdf-wrapper.sh, it will show you this as an option and it will try to execute that file, if you selected it.

Again, a solution like wkhtmltopdf is very complicated to setup in a shared hosting environment as you don't really control it. That's why I am keeping those words in the module page. The most that I am willing to do is to add a link in the documentation to that stackoverflow article as a possible pointer for others..

João

ukrdrupal’s picture

João - Thank you for your response. It is a fair response and I respect your answer.

I fully realize that you cannot or will not support everything. After all, the wkhtmltopdf does work as a static installation, with the x11 libs installed on a hosting environment.

I think the wkhtmltopdf is progressing at a rapid enough rate, with some really amazing progression. I have a theory that they will eventually not even need the x11 libs installed and that the wkhtmltopdf will be able to handle it on it's own. At least, this is my hope. It used to be that you needed the xserver. Now you don't. So, progress is being made.

These posts of mine are really for anyone knowledgable and motivated to help, for the sake of a shared hosting environment, where the hosting company won't install the x11 libs. I wish they would just install them; it would make all of our lives a lot easier. But of course, they want us all to purchase vps hosting or some kind of cloud hosting or a dedicated server plan or something. So, they don't have the incentive to install these libraries.

Again, I am just curious if anyone else had actually worked out a solution with your wonderful print module, wkhtmltopdf static version and some kind of wrapper or another solution, to get the .so files usable by the wkhtmltopdf.

My motivation, as I believe is very evident, is not debate. And I want to make sure that my posts are properly interpreted. Thanks for your time, João!!!

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

The wrapper part is easy and doesn't need much as I explained in #10 (just a rename of the script).

The problem is the set of shared libraries which will be very particular to your local environment. In my case, wkhtmltopdf is complaining about a missing libXrender.so.1. I know that I have to get the libxrender1 .deb file from Debian 4.0 (etch), but I can't find any mirror of that version.

In your case, you'll need to get CentOS4 packages, unpack them, and use the wrapper.

João

ukrdrupal’s picture

João, thank you. Yes, I think you are correct. And getting the .so files for the individual Linux distribution is a real problem. For instance, I could not find everything for CentOS 4. Obviously, it would be easier to install the libX11, on the part of the hosting company. But again, they have an incentive not to. And God forbid the hosting company decides to upgrade from CentOS 4 to CentOS 5. All of the .so files are no longer valid for your Drupal site. ...If anyone else has another solution, I would love to hear about it!

ukrdrupal’s picture

João, I have updated the StackOverflow question to reflect the situation and solution request more accurately at this time:

http://stackoverflow.com/questions/3763417/how-do-i-get-wkhtmltopdf-runn...

I am wondering if you could take a moment to look at the post, with fresh eyes. I am curious if you would be able to tweak the shell script to get it to work or lend some insight into it.

I was mis-informed by my hosting company about the specs on the server. I did some double-checking myself and so now I have been able to obtain all of the .so files that "jockie" had listed in his solution here:

http://stackoverflow.com/questions/2273534/how-to-install-wkhtmltopdf-on...

Is that a complete list of x11 lib .so files needed, for the wkhtmltopdf to run? ...Anyway, if you can read my post again, it may be more useful. Let me know. I appreciate anyone's input into this, to get it to work with your print module. I'll be REALLY excited to get this to work!

drupalnesia’s picture

You're reply really didn't help at all.

I try to help you, if you don't like my solution you can try another solution but I worry if X11 Client libs is the only working and fastest solution without raise any issues. There are many Share hosting companies provide X11 Client libs, BUT ... you must really understand that rendering pdf may eat much cpu/memory resources that's why some hosting company offer you to use VPS, otherwise you will make overload then shutdown the whole SHARE hosting.

I wonder you still use CentOS 4.0, while most servers running CentOS 5.5.

ukrdrupal’s picture

@drupal-id.com - One of the things that I found out is that my hosting company mis-informed me. The server is actually running CentOS 5.5. You know, it's the age-old problem of an inexperienced tech giving you an answer. When I was chatting with tech support, asking them about wkhtmltopdf and the x11 libs, I assumed that the answer (about the distro version) was right and went with that information. However, like you, it just didn't sound right. So, I got on SSH last night and ran several commands and found out that it is running CentOS 5.

About generation of PDFs and memory resources, not to sound insulting, but I really don't care. It is a very brief burst of resources and if their machines are really that pathetic to be shut down (which they are not), then they don't deserve to be in business. My sites will not have millions of users. At any given time, there will only be one person printing to PDF. And that may happen only several times a week. Really.

So, thank you, but now back to solutions. Can someone help me? (By the way, I did revise the Stack Overflow posting; I don't know if you read that before responding here.)

ukrdrupal’s picture

Woah, I think I am in business! ...So, figuring out the specs on the machine also made me aware that it was not a 64 bit machine, but a 32 bit machine. So, I switched the static file over to i386 and now I am able to output PDFs with wkhtmltopdf! Apparently the wkhtmltopdf HAS advanced enough that it is able to print on it's own?! :-) Cool! ...I suppose it is *possible* that some needed fonts, etc., are installed on the hosting so that it can output as well, but I am really happy right now! I'll be able to use wkhtmltopdf on this shared host!

ukrdrupal’s picture

One other thing. I doubt leaving the "-i386" on the name of the file helps, but I did do that. The strange thing is, I had actually tried to use the i386 before, but it did not work. I know I have been renaming the files, cutting off the "-i386" and "-amd64". Crazily enough, could that affect anything?

ukrdrupal’s picture

Also, I simply do not see the print choice showing up in the admin/reports/status, like it did. It shows up, if i chose dompdf, for instance. Or on my other host (CentOS 5, 64bit, with all of the xlibs installed), it will show up in the admin/reports/status. So, why do you think it would not show up here, though it is running and appears to be working?

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Fixed

It only shows up in that page if there's an error of some kind. SInce there's no error, nothing is reported.

The -i386 and -amd64 are not important. The module will list as choices anything that starts with wkhtmltopdf.

Anyway, glad to know you got it fixed.

João

Status: Fixed » Closed (fixed)

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

rajendra15’s picture

Title: wkhtmltopdf on A Shared Host » Unable to find wkhtmltopdf folder and its files in print module as given in print-wkhtmltopdf.patch file
Component: Documentation » Code
Priority: Normal » Critical
Status: Closed (fixed) » Active

I want to take pdf using print module in my application. I found print-wkhtmltopdf.patch file in drupal.org before integrating to application. As given from patch file i had not found wkhtmlpdf directory and files. So I'm unable to load print module into my application. Please give the solution to use patch file in print module to generate PDF.
And what is the maximum file size will be taken by wkhtmltopdf to convert to PDF. Suggest me how to convert 520KB file to PDF.
Thanks in advance.............

rajendra15’s picture

Title: Unable to find wkhtmltopdf folder and its files in print module as given in print-wkhtmltopdf.patch file » I'm working on share host for pdf using wkhtmltopdf. while executing command to get pdf i'm getting the following error

The error is /lib/tls/libc.so.6: version `GLIBC_2.4` not found (required by wkhtmltopdf)
Can anyone help for this error.

Thanks in advance

jcnventura’s picture

Status: Active » Closed (fixed)

Please don't reopen issues on unrelated problems.

The glibc problem will require you to either install a that version of glibc in your system or to recompile wkhtmltopdf in your host server to match the existing libraries. On a shared host, you'll probably not have permission to do any of those options, so you'll be unable to use that library.

Setting back to the original status.