Skip to content

Instantly share code, notes, and snippets.

@damphyr
Created July 4, 2013 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damphyr/5927322 to your computer and use it in GitHub Desktop.
Save damphyr/5927322 to your computer and use it in GitHub Desktop.
Reproduces the pdfkit 0.5.3 behaviour with paths that contain spaces on Windows. Tested with RubyInstaller Ruby 1.9.3p392
require 'pdfkit'
def reproduce html,output,path_to_wk
PDFKit.configure do |config|
config.wkhtmltopdf = path_to_wk
end
kit=PDFKit.new(html,:page_size=>'A4')
kit.to_file(output)
end
html =<<-EOT
<html>
<body><h1>Hello World</h1></body>
</html>
EOT
output="test.pdf"
path_to_wk='c:/Program Files/wkhtmltopdf/wkhtmltopdf.exe'
#D:/tools/ruby/lib/ruby/gems/1.9.1/gems/pdfkit-0.5.3/lib/pdfkit/pdfkit.rb:66:in `popen': No such file or direct
#ory - "c:/Program\ Files/wkhtmltopdf/wkhtmltopdf.exe" "--page-size" "A4" "--margin-top" "0.75in"
#"--margin-right" "0.75in" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--quiet" "-" "test.pdf"
# (Errno::ENOENT)
reproduce(html,output,path_to_wk)
path_to_wk='"c:/Program Files/wkhtmltopdf/wkhtmltopdf.exe"'
#D:/tools/ruby/lib/ruby/gems/1.9.1/gems/pdfkit-0.5.3/lib/pdfkit/pdfkit.rb:31:
#in `initialize': No wkhtmltopdf executable found at "c:/Program Files/wkhtmltopdf/wkhtmltopdf.exe"
#(PDFKit::NoExecutableError)
#>> Please install wkhtmltopdf - https://github.com/jdpace/PDFKit/wiki/Installing-WKHTMLTOPDF
reproduce(html,output,path_to_wk)
path_to_wk='c:\Program Files\wkhtmltopdf\wkhtmltopdf.exe'
#D:/tools/ruby/lib/ruby/gems/1.9.1/gems/pdfkit-0.5.3/lib/pdfkit/pdfkit.rb:66:in `popen': No such file or direct
#ory - "c:\\Program\ Files\\wkhtmltopdf\\wkhtmltopdf.exe" "--page-size" "A4" "--margin-top" "0.75in"
#"--margin-right" "0.75in" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--quiet" "-" "test.pdf"
#(Errno::ENOENT)
reproduce(html,output,path_to_wk)
path_to_wk='"c:\Program Files\wkhtmltopdf\wkhtmltopdf.exe"'
#D:/tools/ruby/lib/ruby/gems/1.9.1/gems/pdfkit-0.5.3/lib/pdfkit/pdfkit.rb:31:
#in `initialize': No wkhtmltopdf executable found at "c:\Program Files\wkhtmltopdf\wkhtmltopdf.exe"
#(PDFKit::NoExecutableError)
#>> Please install wkhtmltopdf - https://github.com/jdpace/PDFKit/wiki/Installing-WKHTMLTOPDF
reproduce(html,output,path_to_wk)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment