Rails 3 + PDFKit Problem: Permission denied (Errno::EACCES)

蹲街弑〆低调 提交于 2019-12-01 11:10:24

问题


I would like to use PDFKit in my Rails 3 application on Windows.

I installed wkhtmltopdf and the pdfkit gem.

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

I got the following error:

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"

Any ideas ?


回答1:


You will get that error if you point to a folder and not the actual file (.exe)

I got PDFkit to run on windows like this:

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


来源:https://stackoverflow.com/questions/5176239/rails-3-pdfkit-problem-permission-denied-errnoeacces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!