2

Windows 上の Rails 3 アプリケーションでPDFKitを使用したいと考えています。

私は宝石をインストールwkhtmltopdfしました。pdfkit

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"

何か案は ?

4

1 に答える 1

13

実際のファイル(.exe)ではなくフォルダーを指定すると、そのエラーが発生します。

次のようなウィンドウでPDFkitを実行しました:

  PDFKit.configure do |config|
    config.wkhtmltopdf = 'C:\wkhtmltopdf\wkhtmltopdf.exe'
  end
于 2011-03-03T04:52:06.003 に答える