2011-03-03 78 views
1

我想在我的Rails 3应用程序中使用PDFKit在Windows上。Rails 3 + PDFKit问题:权限被拒绝(Errno :: EACCES)

我安装wkhtmltopdfpdfkit宝石。

这里是我用来创建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" 

任何想法?

回答

10

,如果你指向一个文件夹,而不是实际文件(.exe)的

我PDFkit像这样在Windows上运行你会得到这个错误:

PDFKit.configure do |config| 
    config.wkhtmltopdf = 'C:\wkhtmltopdf\wkhtmltopdf.exe' 
    end 
+0

谢谢很多!现在它可以工作。我不知道你能不能帮我也有这样一条:http://stackoverflow.com/questions/5177074/rails-3-pdfkit-how-to-print-a-view-to-pdf。非常感谢! – 2011-03-03 05:39:21

相关问题