简体   繁体   中英

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

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM