【问题标题】:Permission denied using wicked_pdf使用 wicked_pdf 拒绝权限
【发布时间】:2013-03-07 22:41:37
【问题描述】:

我正在使用

Windows 7  
Rails 3.2.11  
wkhtmltopdf 0.9.9

在宝石文件中

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:/用户/bob/wful ts_rails_demo/Course_Stats/wicked_pdf_generated_file20130307-6328-n902yj.pdf\" * ******" RuntimeError: 无法执行:"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”错误: 权限被拒绝 - "C:\wkhtmltopdf" "file:///C:/Users/bob/wful ts_rails_demo/Course_Stats/wicked_pdf20130307-6328-7cuwz7.html" “C:/用户/鲍勃 /bob_rails_demo/Course_Stats/wicked_pdf_generated_file20130307-6328-n902yj.pd F” 来自 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' 来自 (irb):1 来自 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' 来自 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' 来自脚本/rails:6:in `'

如果我把这行改成这个...

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

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

【问题讨论】:

  • wkhtmltopdf 在 windows 命令行中自行运行良好

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


【解决方案1】:

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

所以我把它改成了C:\wkhtmltopdf\wkhtmltopdf.exe(你已经有了),然后我把:exe_path变成了这个::exe_path =&gt; 'C:\wkhtmltopdf\wkhtmltopdf.exe'

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

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

【讨论】:

  • 我的 bin 文件夹中有 wkhmltopdf 和 wkhtmltopdf.bat。指定其中任何一个都不起作用。
【解决方案2】:

我遇到了同样的问题,我的诀窍是更改文件的权限:

chmod o+w /usr/local/bundle/gems/wkhtmltopdf-binary-0.12.6.5/bin/

【讨论】:

    猜你喜欢
    • 2011-03-13
    • 2015-04-03
    • 2020-08-09
    • 1970-01-01
    • 1970-01-01
    • 2014-12-14
    • 1970-01-01
    • 1970-01-01
    • 2011-09-21
    相关资源
    最近更新 更多