wicked_pdf
wicked_pdf copied to clipboard
freezes
Hi,
So I'm using the current master head and have this code:
def show
respond_with claim do |format|
format.pdf do
render pdf: claim.number.gsub(/[^0-9a-z]/i, '_'), layout: 'print.html'
end
end
end
and once it gets to here:
"***************\"/usr/local/bin/wkhtmltopdf\" -q - - ***************"
It just freezes. When I kill the server with ctrl + c it then renders the pdf.... any ideas on what's going wrong?
Many thanks
p.s. I'm using the latest home brew version /usr/local/Cellar/wkhtmltopdf/0.11.0_rc1
So I found out something very strange, it's showing the wkhtmltopdf bin icon in the dock and when I click on it then it completes generating the pdf. I'm using mac osx 10.7.3....
I can verify the exact same behaviour with OS X 10.7.4.
I encounter this issue with OS X 10.7.4 and 0.10.0 rc2 (but strangely brew said I install 0.11.0_rc1, but the command line version is 0.10)
Only after you the process icon on the "dock" will it quickly render and exit.
+1 on 10.7.4 and /usr/local/Cellar/wkhtmltopdf/0.11.0_rc1/bin/wkhtmltopdf
.
This issue isn't specific to wicked_pdf, I'm having the same problem with PDFKit. The problem didn't appear until I installed 0.11.0_rc1 via homebrew. I stumbled on this ticket while trying to track down whether or not this was an issue with the wkhtmltopdf binary that comes with homebrew.
I see this issue as well. which wkhtmltopdf
shows /usr/local/bin/wkhtmltopdf
which is a link to ../Cellar/wkhtmltopdf/0.11.0_rc1/bin/wkhtmltopdf
. However, I see the 0.10 when I run wkhtmltopdf --version
.
Hi,
The problem comes from wkhtmltopdf. It has been reported at http://code.google.com/p/wkhtmltopdf/issues/detail?id=141. I also used OSX 10.7.4 and wkhtmltopdf 0.11.rc1.
By waiting a solution, I moved back to 0.9.9 and it works.
Currently running OSX 10.7.4 and wkhtmltopdf 0.9.9 and this isn't working for me. wkhtmltopdf bin icon appears in my dock but clicking it or exiting it does nothing and Firefox just outputs a "Connection was reset" error after approx 10 seconds.
Same problem. OSX 10.7.4, wkhtmltopdf 0.10.0 rc2 (installed by homebrew).
I got this working in the end. Rolling back to version 0.9.9 fixed the problem for me.
I also had to be careful as i was using Unicorn with a process timeout of 30s. I had some PDF's (before optimisation) which were taking longer than 30s to generate so i was getting timeout errors, as you'd expect.
If you're not sure about how to rollback to an older package version using Homebrew, i did a writeup here: Homebrew and installing old package versions.
Same problem here. Tried so many different options. Such a simple task, so many problems with dependencies and native extensions..
I'm on OS 10.6.8, same issue. Solved by rolling back wkhtmltopdf to 0.9.9. Now the wkhtmltopdf shell just pops up and disappears, leaving a beautiful pdf in the browser. Here's full steps, for newbs:
Step 1: uninstall wkhtmltopdf $ brew uninstall wkhtmltopdf Uninstalling /usr/local/Cellar/wkhtmltopdf/0.11.0_rc1...
Step 2: find version 0.9.9 $ brew versions wkhtmltopdf 0.11.0_rc1 git checkout aa80fbc /usr/local/Library/Formula/wkhtmltopdf.rb 0.9.9 git checkout 6e2d550 /usr/local/Library/Formula/wkhtmltopdf.rb
Step 3: Copy and paste the git checkout command (everything from git over to the right): $ git checkout 6e2d550 /usr/local/Library/Formula/wkhtmltopdf.rb
Step 4: reinstall $ brew install wkhtmltopdf
The last output line should say something like /usr/local/Cellar/wkhtmltopdf/0.9.9: 6 files, 424K, built in 15 seconds
Before step 3 you have to cd to /usr/local/Library/Formula/ otherwise you will get a fatal: '/usr/local/Library/Formula/wkhtmltopdf.rb' is outside repository
error.
Same problem here: OSX 10.7.5 and newest wkhtmltopdf from homebrew. The solution to roll back to 0.9.9 works fine for me.
Thanks for the dialog. I have documented the correct installation of 0.9.9 here: http://stackoverflow.com/questions/12517640/why-does-pdfkit-wkhtmltopdf-hang-but-renders-pdf-as-expected-when-rails-app-is-k/14043085#14043085
I've just migrated to 10.8.3 and now, wkhtmltopdf is showing up in the Dock when converting PDF... is there a way to stop this Dock 'appearance'?
If it goes away once the PDF is rendered, don't worry about it. It's just showing that the script is running on your machine. It won't happen in production.
installing 0.9.9 worked for me,
is it possible that it's been two major releases since the last working version?
is this issue happening only to MAC users?
As far as I've ever heard, this only affects OSX builds of wkhtmtopdf binaries. Most production systems run Linux or Windows, that do not suffer this strange behavior, and it is one of the reasons I have recommended in the past for people to stick with 0.9.6. I plan to investigate more this weekend, as that is quite old now, and a few major releases behind.
For information, this seems to be fixed with last binary package from here http://wkhtmltopdf.org/downloads.html I just installed 0.12.1 (carbon edition) and it worked
Well not so bright: I still have some PDF not working. Apparently it hangs for larger files like this : https://gist.github.com/dbourguignon/59668a75c739ced50eb4 with big CSS data But using command line on this file work well.
~~wkhtmltopdf 0.12.2.1 with wicked_pdf 0.9.9 or 0.11.0 on OS X 10.10.1 got same problem.~~
See my next comment.
For people who use Puma. You need at least 2 process worker. With only 1 worker it will freeze. Change to 2 workers worked for me. The number of process workers can be set in config/puma.rb
.
@JuanitoFatas I hang when using 'rails s' to serve my app on Mac. Any idea if this is related / is there a way to increase # of workers using the default rails s?
Hi People I was struggling to make it work but I was having constant freezes, all as described in previous messages here. I am Cent OS 6.6 64bits, with latest binary 0.12.2.1 downloaded from http://wkhtmltopdf.org/downloads.html . I am new to this project, but when I heard lots of complain I thought that it would not be possible to use it.
Luckily after reading these posts and thanks to @beerlington saying that he had problem after installing the 0.11.0_rc1 I installed a previous version 0.10.0_rc2 which is now working fine with no freezes. I also noticed that even charts generated by flot improved quality with same settings I was using before.
It seems that problem occurred with version 0.11.0_rc1 and it is common to every platform.
Despite this, after all is working now smoothly, I can say it is a great project.
It freezes with version 0.10.0 rc2.
just comment below line if you face issues again (from application.rb).
config.middleware.use WickedPdf::Middleware
The wkhtmltopdf
(0.12.4 on MacOS) binary hangs if the following conditions are met:
- wicked_pdf is used as middleware in a Rails app.
- There are external resources (JS, CSS, images etc) used by the view.
- The server is bound to localhost or 127.0.0.1
Funny enough, when I run the dumped wkhtmltopdf
command in a separate terminal, the PDF is generated without any problem.
Here's a workaround: External resources must not be fetched from localhost. When I serve local development through a remote proxy which tunnels the request back to my locally running server, everything works just fine. (I haven't tried localtunnel, you might want to have a go.)
So the question seems to be: Why can wkhtmltopdf
fetch resources from localhost when run in a full interactive shell, but fails to do so when run by wicked_pdf as middleware?
@svoop The middleware is a lot dumber bout how it fetches resources. It catches the HTML as rendered before it gets served, and swaps out relative URLs with absolute ones here.
Otherwise, you'd have to customize every page to use wicked_pdf_*
helpers, which is very un-middleware-like, in my opinion.
Works for me with 127.0.0.1:3000 instead of localhost:3000