Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6528723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:33:40+00:00 2026-05-25T09:33:40+00:00

I’m using PDFKit (which uses wkhtmltopdf ) in an attempt to render a view

  • 0

I’m using PDFKit (which uses wkhtmltopdf) in an attempt to render a view as pdf within a Rails 3 app.

PDFKit renders with Errno::EPIPE (Broken pipe) pointing to send_data(kit.to_pdf, :filename => "generated.pdf", :type => 'application/pdf') in my controller show action:

# Controller
def show
  respond_to do |format|
    format.html { render }
    format.pdf do
      html = render_to_string(:layout => false , :action => "show.html.haml")
      kit = PDFKit.new(html)
      send_data(kit.to_pdf, :filename => "invoice.pdf", :type => 'application/pdf')
      return # to avoid double render call
    end
  end
end

# Gemfile
...
gem 'pdfkit'
gem 'wkhtmltopdf'
...

I know wkhtmltopdf is not the source of this error as wkhtmltopdf public/404.html tmp/404.pdf from within Rails.root works as expected.

I’m using an example from jonathanspies.com after using the middleware failed in the same manner.

# config/application.rb
require 'pdfkit'
config.middleware.use PDFKit::Middleware

After trying it in a fresh Rails 3 app, I get the following error:

command failed: "~/.rvm/gems/ree-1.8.7-2011.01@blog/bin/wkhtmltopdf" "--page-size" "Letter" "--margin-right" "0.75in" "--margin-top" "0.75in" "--margin-bottom" "0.75in" "--encoding" "UTF-8" "--margin-left" "0.75in" "--quiet" "-" "-"

Running the command manually and usage screen is displayed, looking at the –quiet option it is easy to see its supposed to be –quit

Change /lib/pdfkit/pdfkit.rb:35 to the following and everything works as expected (with middleware too).

args << '--quit'

So, once again, I’ve solved my problem in the act of writing the question to get help (always pays to include detail). I submitted a pull request which corrects the spelling mistake (always a silly mistake which gets unnoticed). Hope nobody minds me posting anyways.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:33:40+00:00Added an answer on May 25, 2026 at 9:33 am

    Regarding changing the quiet argument to quit.

    This change is only valid if you are using the wkhtmltopdf gem which uses a very old version of the wkhtmltopdf binary.

    With the wkhtmltopdf gem

    10:32:15 wkhtml >     wkhtmltopdf --version
    wkhtmltopdf 0.8.3 using wkhtmltopdf patched qt
    Copyright (C) 2008,2009 Jakob Truelsen,
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    
    Written by Jakob Truelsen
    Patches by Mário Silva and Emmanuel Bouthenot
    
    10:32:16 wkhtml >     wkhtmltopdf --help | grep quit
      -q, --quit                      Be less verbose.
    10:32:16 wkhtml >     wkhtmltopdf --help | grep quite
    10:32:19 wkhtml > 
    

    With the latest binary I have installed

    10:33:40 tmp > wkhtmltopdf --version
    Name:
      wkhtmltopdf 0.9.9
    
    License:
      Copyright (C) 2008,2009 Wkhtmltopdf Authors.
    
    
    
      License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
      This is free software: you are free to change and redistribute it. There is NO
      WARRANTY, to the extent permitted by law.
    
    Authors:
      Written by Jakob Truelsen. Patches by Mário Silva, Benoit Garret and Emmanuel
      Bouthenot.
    
    10:33:50 tmp > wkhtmltopdf --help | grep quit
    10:34:02 tmp > wkhtmltopdf --help | grep quiet
      -q, --quiet                         Be less verbose
    10:34:07 tmp > 
    

    The spelling mistake exists in the old binary that comes with the wkhtmltopdf gem. I would suggest you monkey patch pdfkit with an initialize or something based on if you included the wkhtmltopdf gem or not.

    I would also accept a pull request that made pdfkit aware of the version of wkthtmltopdf it was running against and conditionally switched that argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.