Created
July 4, 2013 12:35
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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