Skip to content

Instantly share code, notes, and snippets.

@bhauff
Created April 4, 2011 19:31
Show Gist options
  • Select an option

  • Save bhauff/902249 to your computer and use it in GitHub Desktop.

Select an option

Save bhauff/902249 to your computer and use it in GitHub Desktop.
C:\data\brandonh\Dev>jruby -v
jruby 1.6.0 (ruby 1.8.7 patchlevel 330) (2011-03-15 f3b6154) (Java HotSpot(TM) Client VM 1.6.0_21) [Windows XP-x86-java]
C:\data\brandonh\Dev>jruby -S irb
irb(main):001:0> require 'rubygems'
=> false
irb(main):002:0> require 'pdfkit'
=> true
irb(main):003:0> html = '<html><head><title>Hello World!</title></head><p>Hello World!</p></html>'
=> "<html><head><title>Hello World!</title></head><p>Hello World!</p></html>"
irb(main):004:0> # Config for non-standard wkhtmltopdf location
irb(main):005:0* PDFKit.configure {|c| c.wkhtmltopdf = 'C:\data\brandonh\Dev\ruby\libs\wkhtmltopdf.exe'}
=> "C:\\data\\brandonh\\Dev\\ruby\\libs\\wkhtmltopdf.exe"
irb(main):006:0> kit = PDFKit.new(html, :page_size => 'Letter')
=> #<PDFKit:0x5b24c @source=#<PDFKit::Source:0x1558dc @source="<html><head><title>Hello World!</title></head><p>Hello Wo
rld!</p></html>">, @options={"--page-size"=>"Letter", "--margin-top"=>"0.75in", "--margin-right"=>"0.75in", "--margin-bo
ttom"=>"0.75in", "--margin-left"=>"0.75in", "--encoding"=>"UTF-8"}, @stylesheets=[]>
irb(main):007:0> pdf = kit.to_pdf
'C:\data\brandonh\Dev\ruby\libs\wkhtmltopdf.exe" "--page-size" "Letter" "--margin-top" "0.75in" "--margin-right" "0.75in
" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--quiet" "-" "-' is not recognized as an int
ernal or external command,
operable program or batch file.
RuntimeError: command failed: "C:\data\brandonh\Dev\ruby\libs\wkhtmltopdf.exe" "--page-size" "Letter" "--margin-top" "0.
75in" "--margin-right" "0.75in" "--margin-bottom" "0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--quiet" "-" "
-"
from C:/jruby-1.6.0/lib/ruby/gems/1.8/gems/pdfkit-0.5.0/lib/pdfkit/pdfkit.rb:71:in `to_pdf'
from (irb):7:in `evaluate'
from org/jruby/RubyKernel.java:1087:in `eval'
from C:/jruby-1.6.0/lib/ruby/1.8/irb.rb:158:in `eval_input'
from C:/jruby-1.6.0/lib/ruby/1.8/irb.rb:271:in `signal_status'
from C:/jruby-1.6.0/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1417:in `loop'
from org/jruby/RubyKernel.java:1190:in `catch'
from C:/jruby-1.6.0/lib/ruby/1.8/irb.rb:154:in `eval_input'
from C:/jruby-1.6.0/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1190:in `catch'
from C:/jruby-1.6.0/lib/ruby/1.8/irb.rb:70:in `start'
from C:/jruby-1.6.0/bin/jirb:13:in `(root)'
irb(main):008:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment