PDFKit in rails gives service 500 error
I am trying to use pdfkit in windows in my rails 2.3 environment. However the middleware that pdfkit gives some error which causes rails to load the service error. What do i do about this? Are there any alternatives to PDFkit which are easy to use ?
Well i am currently following the Rails screencast on PDFKit. I installed the pdfkit gem ,wkhtmltopdf and then loaded the 开发者_运维问答middleware in the environment.rb file as require 'pdfkit' config.middleware.use "PDFKit::Middleware" then when i go to any page and add the .pdf extension i get the 500 server error
/!\ FAILSAFE /!\ Sun Jul 11 18:42:53 +0530 2010 Status: 500 Internal Server Error private method
chomp' called for nil:NilClass C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/whiny_nil.rb:52:in
method_missing' C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/pdfkit-0.3.3/lib/pdfkit/pdfkit.rb:69:inwkhtmltopdf' C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/pdfkit-0.3.3/lib/pdfkit/pdfkit.rb:33:in
initialize' C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/pdfkit-0.3.3/lib/pdfkit/middleware.rb:25:innew' C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/pdfkit-0.3.3/lib/pdfkit/middleware.rb:25:in
call' C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:incall' C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in
call' C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:incall' C:/Program Files/BitNami RubyStack/ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in
call'
If you are using pdfkit on windows you need to install the wkhtmltopdf. After it you will need to configure the wkhtmltopdf on your enviroment.rb like this :D.
PDFKit.configure do |config|
config.wkhtmltopdf = 'C:\opt\wkhtmltopdf\wkhtmltopdf.exe'
config.default_options = {
:page_size => 'Legal',
:print_media_type => true
}
config.root_url = "http://localhost" # Use only if your external hostname is unavailable on the server.
end
I hope this helps.
精彩评论