windows - 使用 wicked_pdf 拒绝权限

标签 windows ruby-on-rails-3 windows-7 wicked-pdf

我正在使用

Windows 7  
Rails 3.2.11  
wkhtmltopdf 0.9.9

在gem文件中

gem 'wicked_pdf'

在我的初始化程序中

WickedPdf.config = { :exe_path => 'C:\wkhtmltopdf' }

Exe位于

C:\wkhtmltopdf\wkhtmltopdf.exe

当我从 Rails c 运行时

irb(main):001:0> WickedPdf.new.pdf_from_string('<h1>Hello There!</h1>')

我收到以下错误...

"*******\"C:\wkhtmltopdf\"
\"file:///C:/Users/bob/bob_rail s_demo/Course_Stats/wicked_pdf20130307-6328-7cuwz7.html\" \"C:/Users/bob/wful ts_rails_demo/Course_Stats/wicked_pdf_generated_file20130307-6328-n902yj.pdf\" * ******" RuntimeError: Failed to execute: "C:\wkhtmltopdf" "file:///C:/Users/bob/bob_rails_demo/Course_Stats/ wicked_pdf20130307-6328-7cuwz7.html" "C:/Users/bob/bob_rails_demo/Course_S tats/wicked_pdf_generated_file20130307-6328-n902yj.pdf" Error: Permission denied - "C:\wkhtmltopdf" "file:///C:/Users/bob/wful ts_rails_demo/Course_Stats/wicked_pdf20130307-6328-7cuwz7.html" "C:/Users/bob /bob_rails_demo/Course_Stats/wicked_pdf_generated_file20130307-6328-n902yj.pd f" from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/wicked_pdf-0.9 .4/lib/wicked_pdf.rb:50:in rescue in pdf_from_string' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/wicked_pdf-0.9 .4/lib/wicked_pdf.rb:34:inpdf_from_string' from (irb):1 from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/commands/console.rb:47:in start' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/commands/console.rb:8:instart' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1 1/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `'

如果我将此行更改为...

WickedPdf.config = { :exe_path => 'C:\wkhtmltopdf\wkhtmltopdf.exe' }

然后在 Rails 命令行中运行它,它似乎可以工作,但在我的应用程序中,Rack 中间件只是挂起......

最佳答案

我遇到了同样的问题,除了最初我的 exe 位于 C:\Program Files (x86)\wkhtmltopdf\wkhtmltopdf.exe

所以我将其更改为 C:\wkhtmltopdf\wkhtmltopdf.exe (你已经有了),然后我将我的 :exe_path 设置为: :exe_path => 'C:\wkhtmltopdf\wkhtmltopdf.exe'

我相信您必须在 Windows 环境中添加 .exe 的原因是因为 Windows 需要显式指定文件路径。一旦我这样做了,它就像一个魅力。

让我知道进展如何(或进展如何)!

关于windows - 使用 wicked_pdf 拒绝权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15283229/

相关文章:

c++ - 在 Windows 中使用 MinGW 的谷歌 Protocol Buffer

c++ - 如何从 ULONGLONG 毫秒创建 SYSTEMTIME 结构?

ruby-on-rails - 在routes.rb中设计current_user

mysql - 此版本的 mysql2 (0.2.18) 与 Rails 3.1 不兼容

ruby-on-rails-3 - Minitest w/Rails 中的匿名 Controller

visual-studio - 值不能为空。参数名称 : userContext in Visual Studio 2017

c# - 将窗口置于前台的问题

windows - 如何读出引导顺序?

asp.net-mvc - 正确设置 IIS Express SSL 证书以开发 .net 核心 mvc 应用程序

windows - 如何以编程方式解锁窗口