[英]Rails 3 + PDFKit Problem: Permission denied (Errno::EACCES)
我想在Windows的 Rails 3應用程序中使用PDFKit 。
我安裝了wkhtmltopdf
和pdfkit
gem。
這是我用來創建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),則會出現該錯誤。
我讓PDFkit在這樣的Windows上運行:
PDFKit.configure do |config|
config.wkhtmltopdf = 'C:\wkhtmltopdf\wkhtmltopdf.exe'
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.