kit.to_file call never returns #200

thbar opened this Issue Sep 13, 2013 · 16 comments


None yet

8 participants

thbar commented Sep 13, 2013

The call to to_file seems to hang the execution on my setup.

Here is the code (I'm new to pdfkit so I may make an obvious mistake, but in case):

task :default do
  require 'redcarpet'
  require 'pdfkit'

  content ='')
  options = []
  markdown =, *options)

  kit =, :page_size => 'Letter')

  puts "Calling to_file"
  file = kit.to_file('inventory.pdf')
  puts "After to_file"

"After to_file" is never displayed (but the pdf is properly generated).

My configuration:

  • ruby-1.9.3-p448 (with railsexpress patches, but I tried with 2.0.0 and see the same behaviour)
  • pdfkit 0.5.4
  • redcarpet 3.0.0

Thanks for the awesome and detailed report. I'll try and reproduce this later today or over the weekend. In the meantime have some 🍰

thbar commented Sep 13, 2013

You welcome, sir, and thanks for maintaining this gem. I'll have that 🍰 and some 🍣 too.

cjolly commented Sep 13, 2013

@thbar I've noticed this with the v0.11.0 version of wkpdftohtml installed with brew. I downgraded to the 0.9.9 binary manually installed from with success.


@thbar if you wouldn't mind posting whatever version you're using of wkhtmltopdf. You just need to run wkhtmltopdf --version.

thbar commented Sep 16, 2013

@sigmavirus24 sorry for the delay, here is the output!

0.10.0 rc2

@thbar can you try this with 0.9.9 and report what happens? Ubuntu doesn't have a pre-existing package for wkhtmltopdf for version 0.9.9 but there are a couple of gems you could try out to provide that.

jcoleman commented Apr 9, 2014

I can confirm that I can reproduce the bug if I'm running on 0.10+ but if I downgrade to 0.9.9 it works correctly.

For reference purposes, you can install 0.9.9 on OS X via Homebrew with the following command:

brew install

I'd recommend closing this bug.


@jcoleman I wonder if there's a way to work around this on 0.10+ though. Perhaps there's a way for us to work around it.

cjolly commented Apr 18, 2014

Hi all -
I'm not using wkhtmltopdf anymore, but I did recently notice that the project is being actively maintained again - and they have a new version 0.12.0 that may be worth checking out with regard to this and many, many, many more with the previous versions :). Good luck!


Thanks for the update Chad!

Once 0.12.1 comes out (apparently there's a blocking bug in QT for Mac that
breaks the current build) it'll be worth trying again to see if we can
upgrade without these issues. But until then I think it's a non-starter
since so many people are developing on the Mac.

On Fri, Apr 18, 2014 at 8:02 PM, Ian Cordasco notifications@github.comwrote:

Thanks for the update Chad!

Reply to this email directly or view it on GitHub


0.12.1 was released in late June. Does anyone want to take a look and see if they can get the tests to pass using it?

I am having the same issue on 2 machines:
development machine Mac OS X 10.10.1 (hangs and never returns)
server running RedHat 6.5 (returns an error shown below)
command failed (exitstatus=1): /usr/local/bin/wkhtmltopdf --page-size Letter --margin-top 0.75in --margin-right 0.75in --margin-bottom 0.75in --margin-left 0.75in --encoding UTF-8 - -

wkhtmltopdf 0.12.1 (Manually installed. wkhtmltopdf-binary 0.9.9 gem worked at first in development)
Rails 4.1.8
Ruby 2.1.1
pdfkit 0.6.2

I have the same issue on windows 7.
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Exit with code 1 due to network error: HostNotFoundError

RuntimeError (command failed (exitstatus=1): C:/wkhtmltopdf/bin/wkhtmltopdf.exe --page-size Legal --print-media-type - -):
help me plz


cdwort commented Jun 13, 2015

@Alshurafa @zhangyanan Those look like real failures of the wkhtmltopdf command. PDFKit is erroring out with a message of command failed (exitstatus=1): Most likely that means either a problem with wkhtmltopdf or with your options set up. Those problems should go on StackOverflow first, but if you still think it's a bug feel free to open an issue.

The hanging problem, however, seems to be addressed by downgrading wkhtmltopdf or (most likely) using a newer version. I am closing this issue.

@cdwort cdwort closed this Jun 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment