本文介绍了Rails 3 + PDFKit 问题:权限被拒绝 (Errno::EACCES)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的 Rails 3 应用程序在 Windows 中使用 PDFKit.
I would like to use PDFKit in my Rails 3 application on Windows.
我安装了 wkhtmltopdf
和 pdfkit
gem.
I installed wkhtmltopdf
and the pdfkit
gem.
这是我用来创建 PDF 的代码:
Here is the code that I use to create the PDF:
class JobsController < ApplicationController
def create_pdf_invoice
kit = PDFKit.new("<h1>Hello</h1><p>This is PDF!!!</p>", :page_size => "A4")
file = kit.to_file("my_first_pdf") # Error issued here!!
...
end
end
我收到以下错误:
Errno::EACCES in JobsController#create_pdf_invoice
Permission denied - "c:\Program Files\wkhtmltopdf" "--page-size" "A4"
"--margin-top" "0.75in" "--margin-right" "0.75in"
"--margin-bottom" "0.75in" "--margin-left" "0.75in"
"--encoding" "UTF-8" "--quiet" "-" "my_first_pdf"
有什么想法吗?
推荐答案
如果您指向文件夹而不是实际的文件 (.exe)
You will get that error if you point to a folder and not the actual file (.exe)
我让 PDFkit 像这样在 Windows 上运行:
I got PDFkit to run on windows like this:
PDFKit.configure do |config|
config.wkhtmltopdf = 'C:\wkhtmltopdf\wkhtmltopdf.exe'
end
这篇关于Rails 3 + PDFKit 问题:权限被拒绝 (Errno::EACCES)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!